mm/memory_hotplug.c: spare unnecessary calls to node_set_state
authorOscar Salvador <>
Fri, 26 Oct 2018 22:07:25 +0000 (15:07 -0700)
committerLinus Torvalds <>
Fri, 26 Oct 2018 23:26:33 +0000 (16:26 -0700)
In node_states_check_changes_online, we check if the node will have to be
set for any of the N_*_MEMORY states after the pages have been onlined.

Later on, we perform the activation in node_states_set_node.  Currently,
in node_states_set_node we set the node to N_MEMORY unconditionally.

This means that we call node_set_state for N_MEMORY every time pages go
online, but we only need to do it if the node has not yet been set for

Fix this by checking status_change_nid.

Signed-off-by: Oscar Salvador <>
Reviewed-by: Pavel Tatashin <>
Cc: Michal Hocko <>
Cc: Dan Williams <>
Cc: David Hildenbrand <>
Cc: Jonathan Cameron <>
Cc: <>
Cc: Mathieu Malaterre <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>

index 38d94b703e9d4932279b5657a2c889dfaaf1b749..63facfc5722487d9c843eb48da78f95eb58324fe 100644 (file)
@@ -753,7 +753,8 @@ static void node_states_set_node(int node, struct memory_notify *arg)
        if (arg->status_change_nid_high >= 0)
                node_set_state(node, N_HIGH_MEMORY);
-       node_set_state(node, N_MEMORY);
+       if (arg->status_change_nid >= 0)
+               node_set_state(node, N_MEMORY);
 static void __meminit resize_zone_range(struct zone *zone, unsigned long start_pfn,