mm/memory_hotplug: make unregister_memory_block_under_nodes() never fail

We really don't want anything during memory hotunplug to fail.  We
always pass a valid memory block device, that check can go.  Avoid
allocating memory and eventually failing.  As we are always called under
lock, we can use a static piece of memory.  This avoids having to put
the structure onto the stack, having to guess about the stack size of

Patch inspired by a patch from Oscar Salvador.

In the future, there might be no need to iterate over nodes at all.
mem->nid should tell us exactly what to remove.  Memory block devices
with mixed nodes (added during boot) should properly fenced off and
never removed.

Signed-off-by: David Hildenbrand <>
Reviewed-by: Wei Yang <>
Reviewed-by: Oscar Salvador <>
Acked-by: Michal Hocko <>
Cc: Greg Kroah-Hartman <>
Cc: "Rafael J. Wysocki" <>
Cc: Alex Deucher <>
Cc: "David S. Miller" <>
Cc: Mark Brown <>
Cc: Chris Wilson <>
Cc: David Hildenbrand <>
Cc: Jonathan Cameron <>
Cc: Andrew Banman <>
Cc: Andy Lutomirski <>
Cc: Anshuman Khandual <>
Cc: Ard Biesheuvel <>
Cc: Arun KS <>
Cc: Baoquan He <>
Cc: Benjamin Herrenschmidt <>
Cc: Borislav Petkov <>
Cc: Catalin Marinas <>
Cc: Chintan Pandya <>
Cc: Christophe Leroy <>
Cc: Dan Williams <>
Cc: Dave Hansen <>
Cc: Fenghua Yu <>
Cc: Heiko Carstens <>
Cc: "H. Peter Anvin" <>
Cc: Ingo Molnar <>
Cc: Joonsoo Kim <>
Cc: Jun Yao <>
Cc: "Kirill A. Shutemov" <>
Cc: Logan Gunthorpe <>
Cc: Mark Rutland <>
Cc: Masahiro Yamada <>
Cc: Mathieu Malaterre <>
Cc: Michael Ellerman <>
Cc: Mike Rapoport <>
Cc: "" <>
Cc: Nicholas Piggin <>
Cc: Paul Mackerras <>
Cc: Pavel Tatashin <>
Cc: Peter Zijlstra <>
Cc: Qian Cai <>
Cc: Rich Felker <>
Cc: Rob Herring <>
Cc: Robin Murphy <>
Cc: Thomas Gleixner <>
Cc: Tony Luck <>
Cc: Vasily Gorbik <>
Cc: Will Deacon <>
Cc: Yoshinori Sato <>
Cc: Yu Zhao <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
2 files changed