On Mon, May 27, 2019 at 7:12 AM David Hildenbrand <david@xxxxxxxxxx> wrote: > > Only memory to be added to the buddy and to be onlined/offlined by > user space using /sys/devices/system/memory/... needs (and should have!) > memory block devices. > > Factor out creation of memory block devices. Create all devices after > arch_add_memory() succeeded. We can later drop the want_memblock parameter, > because it is now effectively stale. > > Only after memory block devices have been added, memory can be onlined > by user space. This implies, that memory is not visible to user space at > all before arch_add_memory() succeeded. > > While at it > - use WARN_ON_ONCE instead of BUG_ON in moved unregister_memory() > - introduce find_memory_block_by_id() to search via block id > - Use find_memory_block_by_id() in init_memory_block() to catch > duplicates > > Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> > Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx> > Cc: David Hildenbrand <david@xxxxxxxxxx> > Cc: "mike.travis@xxxxxxx" <mike.travis@xxxxxxx> > Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Cc: Ingo Molnar <mingo@xxxxxxxxxx> > Cc: Andrew Banman <andrew.banman@xxxxxxx> > Cc: Oscar Salvador <osalvador@xxxxxxx> > Cc: Michal Hocko <mhocko@xxxxxxxx> > Cc: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx> > Cc: Qian Cai <cai@xxxxxx> > Cc: Wei Yang <richard.weiyang@xxxxxxxxx> > Cc: Arun KS <arunks@xxxxxxxxxxxxxx> > Cc: Mathieu Malaterre <malat@xxxxxxxxxx> > Signed-off-by: David Hildenbrand <david@xxxxxxxxxx> LGTM Reviewed-by: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx>