Commit c1152583 authored by Wei Yang's avatar Wei Yang Committed by Linus Torvalds

mm/memory_hotplug: just build zonelist for newly added node

Commit 9adb62a5 ("mm/hotplug: correctly setup fallback zonelists
when creating new pgdat") tries to build the correct zonelist for a
newly added node, while it is not necessary to rebuild it for already
exist nodes.

In build_zonelists(), it will iterate on nodes with memory.  For a newly
added node, it will have memory until node_states_set_node() is called
in online_pages().

This patch avoids rebuilding the zonelists for already existing nodes.

build_zonelists_node() uses managed_zone(zone) checks, so it should not
include empty zones anyway.  So effectively we avoid some pointless work
under stop_machine().

[ tweak comment text]
[ coding-style tweak, per Vlastimil]
Link: default avatarWei Yang <>
Acked-by: default avatarMichal Hocko <>
Acked-by: default avatarVlastimil Babka <>
Cc: Jiang Liu <>
Cc: Xishi Qiu <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 912d572d
......@@ -5282,14 +5282,18 @@ static int __build_all_zonelists(void *data)
memset(node_load, 0, sizeof(node_load));
* This node is hotadded and no memory is yet present. So just
* building zonelists is fine - no need to touch other nodes.
if (self && !node_online(self->node_id)) {
for_each_online_node(nid) {
pg_data_t *pgdat = NODE_DATA(nid);
} else {
for_each_online_node(nid) {
pg_data_t *pgdat = NODE_DATA(nid);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment