mm/memory_hotplug: make unregister_memory_section() never fail

Failing while removing memory is mostly ignored and cannot really be
handled.  Let's treat errors in unregister_memory_section() in a nice way,
warning, but continuing.

Link: http://lkml.kernel.org/r/20190409100148.24703-3-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Banman <andrew.banman@hpe.com>
Cc: Mike Travis <mike.travis@hpe.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Qian Cai <cai@lca.pw>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Arun KS <arunks@codeaurora.org>
Cc: Mathieu Malaterre <malat@debian.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Oscar Salvador <osalvador@suse.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rich Felker <dalias@libc.org>
Cc: Rob Herring <robh@kernel.org>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
David Hildenbrand 2019-05-13 17:21:37 -07:00 committed by Linus Torvalds
parent d9eb1417c7
commit cb7b3a3685
3 changed files with 7 additions and 15 deletions

View File

@ -734,15 +734,18 @@ unregister_memory(struct memory_block *memory)
{ {
BUG_ON(memory->dev.bus != &memory_subsys); BUG_ON(memory->dev.bus != &memory_subsys);
/* drop the ref. we got in remove_memory_section() */ /* drop the ref. we got via find_memory_block() */
put_device(&memory->dev); put_device(&memory->dev);
device_unregister(&memory->dev); device_unregister(&memory->dev);
} }
static int remove_memory_section(struct mem_section *section) void unregister_memory_section(struct mem_section *section)
{ {
struct memory_block *mem; struct memory_block *mem;
if (WARN_ON_ONCE(!present_section(section)))
return;
mutex_lock(&mem_sysfs_mutex); mutex_lock(&mem_sysfs_mutex);
/* /*
@ -763,15 +766,6 @@ static int remove_memory_section(struct mem_section *section)
out_unlock: out_unlock:
mutex_unlock(&mem_sysfs_mutex); mutex_unlock(&mem_sysfs_mutex);
return 0;
}
int unregister_memory_section(struct mem_section *section)
{
if (!present_section(section))
return -EINVAL;
return remove_memory_section(section);
} }
#endif /* CONFIG_MEMORY_HOTREMOVE */ #endif /* CONFIG_MEMORY_HOTREMOVE */

View File

@ -113,7 +113,7 @@ extern int register_memory_isolate_notifier(struct notifier_block *nb);
extern void unregister_memory_isolate_notifier(struct notifier_block *nb); extern void unregister_memory_isolate_notifier(struct notifier_block *nb);
int hotplug_memory_register(int nid, struct mem_section *section); int hotplug_memory_register(int nid, struct mem_section *section);
#ifdef CONFIG_MEMORY_HOTREMOVE #ifdef CONFIG_MEMORY_HOTREMOVE
extern int unregister_memory_section(struct mem_section *); extern void unregister_memory_section(struct mem_section *);
#endif #endif
extern int memory_dev_init(void); extern int memory_dev_init(void);
extern int memory_notify(unsigned long val, void *v); extern int memory_notify(unsigned long val, void *v);

View File

@ -526,9 +526,7 @@ static int __remove_section(struct zone *zone, struct mem_section *ms,
if (!valid_section(ms)) if (!valid_section(ms))
return ret; return ret;
ret = unregister_memory_section(ms); unregister_memory_section(ms);
if (ret)
return ret;
scn_nr = __section_nr(ms); scn_nr = __section_nr(ms);
start_pfn = section_nr_to_pfn((unsigned long)scn_nr); start_pfn = section_nr_to_pfn((unsigned long)scn_nr);