NUMA: early use of cpu_to_node() returns 0 instead of the correct node id
[linux-2.6-block.git] / init / main.c
index 6b4b656cef1d9f90cef99d86a9189c528ba64703..0aecd2839c1fd5884e5fa5ff80dc49cc93ce2d18 100644 (file)
@@ -882,6 +882,19 @@ static void __init print_unknown_bootoptions(void)
        memblock_free(unknown_options, len);
 }
 
+static void __init early_numa_node_init(void)
+{
+#ifdef CONFIG_USE_PERCPU_NUMA_NODE_ID
+#ifndef cpu_to_node
+       int cpu;
+
+       /* The early_cpu_to_node() should be ready here. */
+       for_each_possible_cpu(cpu)
+               set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
+#endif
+#endif
+}
+
 asmlinkage __visible __init __no_sanitize_address __noreturn __no_stack_protector
 void start_kernel(void)
 {
@@ -912,6 +925,7 @@ void start_kernel(void)
        setup_nr_cpu_ids();
        setup_per_cpu_areas();
        smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
+       early_numa_node_init();
        boot_cpu_hotplug_init();
 
        pr_notice("Kernel command line: %s\n", saved_command_line);