path: root/mm
diff options
authorNathan Fontenot <>2017-02-24 15:00:02 -0800
committerLinus Torvalds <>2017-02-24 17:46:56 -0800
commitdc18d706a4367454ad1fc51e06148d54e8ecfaa0 (patch)
treec72bb090e93017548b6f50537883e151caf87ac4 /mm
parentdd8416c47715cf324c9a16f13273f9fda87acfed (diff)
memory-hotplug: use dev_online for memhp_auto_online
Commit 31bc3858ea3e ("add automatic onlining policy for the newly added memory") provides the capability to have added memory automatically onlined during add, but this appears to be slightly broken. The current implementation uses walk_memory_range() to call online_memory_block, which uses memory_block_change_state() to online the memory. Instead, we should be calling device_online() for the memory block in online_memory_block(). This would online the memory (the memory bus online routine memory_subsys_online() called from device_online calls memory_block_change_state()) and properly update the device struct offline flag. As a result of the current implementation, attempting to remove a memory block after adding it using auto online fails. This is because doing a remove, for instance echo offline > /sys/devices/system/memory/memoryXXX/state uses device_offline() which checks the dev->offline flag. Link: Signed-off-by: Nathan Fontenot <> Cc: Michael Ellerman <> Cc: Michael Roth <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'mm')
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index c35dd19..1d3ed58 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1337,7 +1337,7 @@ int zone_for_memory(int nid, u64 start, u64 size, int zone_default,
static int online_memory_block(struct memory_block *mem, void *arg)
- return memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE);
+ return device_online(&mem->dev);
/* we are OK calling __meminit stuff here - we have CONFIG_MEMORY_HOTPLUG */