mm/memory_hotplug: simplify and fix check_hotplug_memory_range()

Patch series "mm/memory_hotplug: Factor out memory block devicehandling", v3.

We only want memory block devices for memory to be onlined/offlined
(add/remove from the buddy).  This is required so user space can
online/offline memory and kdump gets notified about newly onlined

Let's factor out creation/removal of memory block devices.  This helps
to further cleanup arch_add_memory/arch_remove_memory() and to make
implementation of new features easier - especially sub-section memory
hot add from Dan.

Anshuman Khandual is currently working on arch_remove_memory().  I added
a temporary solution via "arm64/mm: Add temporary arch_remove_memory()
implementation", that is sufficient as a firsts tep in the context of
this series.  (we don't cleanup page tables in case anything goes wrong

Did a quick sanity test with DIMM plug/unplug, making sure all devices
and sysfs links properly get added/removed.  Compile tested on s390x and

This patch (of 11):

By converting start and size to page granularity, we actually ignore
unaligned parts within a page instead of properly bailing out with an

Signed-off-by: David Hildenbrand <>
Reviewed-by: Dan Williams <>
Reviewed-by: Wei Yang <>
Reviewed-by: Pavel Tatashin <>
Reviewed-by: Oscar Salvador <>
Acked-by: Michal Hocko <>
Cc: David Hildenbrand <>
Cc: Qian Cai <>
Cc: Arun KS <>
Cc: Mathieu Malaterre <>
Cc: Alex Deucher <>
Cc: Andrew Banman <>
Cc: Andy Lutomirski <>
Cc: Anshuman Khandual <>
Cc: Ard Biesheuvel <>
Cc: Baoquan He <>
Cc: Benjamin Herrenschmidt <>
Cc: Borislav Petkov <>
Cc: Catalin Marinas <>
Cc: Chintan Pandya <>
Cc: Christophe Leroy <>
Cc: Chris Wilson <>
Cc: Dave Hansen <>
Cc: "David S. Miller" <>
Cc: Fenghua Yu <>
Cc: Greg Kroah-Hartman <>
Cc: Heiko Carstens <>
Cc: "H. Peter Anvin" <>
Cc: Ingo Molnar <>
Cc: Jonathan Cameron <>
Cc: Joonsoo Kim <>
Cc: Jun Yao <>
Cc: "Kirill A. Shutemov" <>
Cc: Logan Gunthorpe <>
Cc: Mark Brown <>
Cc: Mark Rutland <>
Cc: Masahiro Yamada <>
Cc: Michael Ellerman <>
Cc: Mike Rapoport <>
Cc: "" <>
Cc: Nicholas Piggin <>
Cc: Paul Mackerras <>
Cc: Peter Zijlstra <>
Cc: "Rafael J. Wysocki" <>
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 <>
1 file changed