Commit d7e0b37a authored by Toshi Kani's avatar Toshi Kani Committed by Linus Torvalds

mm: set N_CPU to node_states during boot

After a system booted, N_CPU is not set to any node as has_cpu shows an
empty line.

  # cat /sys/devices/system/node/has_cpu

setup_vmstat() registers its CPU notifier callback,
vmstat_cpuup_callback(), which marks N_CPU to a node when a CPU is put
into online.  However, setup_vmstat() is called after all CPUs are
launched in the boot sequence.

Changed setup_vmstat() to mark N_CPU to the nodes with online CPUs at
boot, which is consistent with other operations in
vmstat_cpuup_callback(), i.e.  start_cpu_timer() and

Also added get_online_cpus() to protect the for_each_online_cpu() loop.
Signed-off-by: default avatarToshi Kani <>
Acked-by: default avatarChristoph Lameter <>
Reviewed-by: default avatarYasuaki Ishimatsu <>
Tested-by: default avatarYasuaki Ishimatsu <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent c5320926
......@@ -1276,8 +1276,12 @@ static int __init setup_vmstat(void)
for_each_online_cpu(cpu) {
node_set_state(cpu_to_node(cpu), N_CPU);
proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
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