Skip to content

Commit cb7b3a3

Browse files
David Hildenbrandtorvalds
authored andcommitted
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>
1 parent d9eb141 commit cb7b3a3

3 files changed

Lines changed: 7 additions & 15 deletions

File tree

‎drivers/base/memory.c‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -734,15 +734,18 @@ unregister_memory(struct memory_block *memory)
734734
{
735735
BUG_ON(memory->dev.bus != &memory_subsys);
736736

737-
/* drop the ref. we got in remove_memory_section() */
737+
/* drop the ref. we got via find_memory_block() */
738738
put_device(&memory->dev);
739739
device_unregister(&memory->dev);
740740
}
741741

742-
static int remove_memory_section(struct mem_section *section)
742+
void unregister_memory_section(struct mem_section *section)
743743
{
744744
struct memory_block *mem;
745745

746+
if (WARN_ON_ONCE(!present_section(section)))
747+
return;
748+
746749
mutex_lock(&mem_sysfs_mutex);
747750

748751
/*
@@ -763,15 +766,6 @@ static int remove_memory_section(struct mem_section *section)
763766

764767
out_unlock:
765768
mutex_unlock(&mem_sysfs_mutex);
766-
return 0;
767-
}
768-
769-
int unregister_memory_section(struct mem_section *section)
770-
{
771-
if (!present_section(section))
772-
return -EINVAL;
773-
774-
return remove_memory_section(section);
775769
}
776770
#endif /* CONFIG_MEMORY_HOTREMOVE */
777771

‎include/linux/memory.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ extern int register_memory_isolate_notifier(struct notifier_block *nb);
113113
extern void unregister_memory_isolate_notifier(struct notifier_block *nb);
114114
int hotplug_memory_register(int nid, struct mem_section *section);
115115
#ifdef CONFIG_MEMORY_HOTREMOVE
116-
extern int unregister_memory_section(struct mem_section *);
116+
extern void unregister_memory_section(struct mem_section *);
117117
#endif
118118
extern int memory_dev_init(void);
119119
extern int memory_notify(unsigned long val, void *v);

‎mm/memory_hotplug.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,7 @@ static int __remove_section(struct zone *zone, struct mem_section *ms,
526526
if (!valid_section(ms))
527527
return ret;
528528

529-
ret = unregister_memory_section(ms);
530-
if (ret)
531-
return ret;
529+
unregister_memory_section(ms);
532530

533531
scn_nr = __section_nr(ms);
534532
start_pfn = section_nr_to_pfn((unsigned long)scn_nr);

0 commit comments

Comments
 (0)