Skip to content

Commit 9d1d887

Browse files
David Hildenbrandtorvalds
authored andcommitted
mm/memory_hotplug: make __remove_section() never fail
Let's just warn in case a section is not valid instead of failing to remove somewhere in the middle of the process, returning an error that will be mostly ignored by callers. Link: http://lkml.kernel.org/r/20190409100148.24703-4-david@redhat.com Signed-off-by: David Hildenbrand <david@redhat.com> Reviewed-by: Oscar Salvador <osalvador@suse.de> Cc: Michal Hocko <mhocko@suse.com> Cc: David Hildenbrand <david@redhat.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: Andrew Banman <andrew.banman@hpe.com> 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@kernel.org> 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: Mike Travis <mike.travis@hpe.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: "Rafael J. Wysocki" <rafael@kernel.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 cb7b3a3 commit 9d1d887

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

‎mm/memory_hotplug.c‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -516,15 +516,15 @@ static void __remove_zone(struct zone *zone, unsigned long start_pfn)
516516
pgdat_resize_unlock(zone->zone_pgdat, &flags);
517517
}
518518

519-
static int __remove_section(struct zone *zone, struct mem_section *ms,
520-
unsigned long map_offset, struct vmem_altmap *altmap)
519+
static void __remove_section(struct zone *zone, struct mem_section *ms,
520+
unsigned long map_offset,
521+
struct vmem_altmap *altmap)
521522
{
522523
unsigned long start_pfn;
523524
int scn_nr;
524-
int ret = -EINVAL;
525525

526-
if (!valid_section(ms))
527-
return ret;
526+
if (WARN_ON_ONCE(!valid_section(ms)))
527+
return;
528528

529529
unregister_memory_section(ms);
530530

@@ -533,7 +533,6 @@ static int __remove_section(struct zone *zone, struct mem_section *ms,
533533
__remove_zone(zone, start_pfn);
534534

535535
sparse_remove_one_section(zone, ms, map_offset, altmap);
536-
return 0;
537536
}
538537

539538
/**
@@ -553,7 +552,7 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
553552
{
554553
unsigned long i;
555554
unsigned long map_offset = 0;
556-
int sections_to_remove, ret = 0;
555+
int sections_to_remove;
557556

558557
/* In the ZONE_DEVICE case device driver owns the memory region */
559558
if (is_dev_zone(zone)) {
@@ -574,16 +573,13 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
574573
unsigned long pfn = phys_start_pfn + i*PAGES_PER_SECTION;
575574

576575
cond_resched();
577-
ret = __remove_section(zone, __pfn_to_section(pfn), map_offset,
578-
altmap);
576+
__remove_section(zone, __pfn_to_section(pfn), map_offset,
577+
altmap);
579578
map_offset = 0;
580-
if (ret)
581-
break;
582579
}
583580

584581
set_zone_contiguous(zone);
585-
586-
return ret;
582+
return 0;
587583
}
588584
#endif /* CONFIG_MEMORY_HOTREMOVE */
589585

0 commit comments

Comments
 (0)