aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/kernel/setup.c2
-rw-r--r--arch/x86_64/mm/numa.c25
-rw-r--r--include/asm-x86_64/numa.h5
3 files changed, 32 insertions, 0 deletions
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 46bf556efc30..173bdc55113b 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -713,6 +713,8 @@ void __init setup_arch(char **cmdline_p)
713 acpi_boot_init(); 713 acpi_boot_init();
714#endif 714#endif
715 715
716 init_cpu_to_node();
717
716#ifdef CONFIG_X86_LOCAL_APIC 718#ifdef CONFIG_X86_LOCAL_APIC
717 /* 719 /*
718 * get boot-time SMP configuration: 720 * get boot-time SMP configuration:
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 42ec1f4f491a..876e34374412 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -330,6 +330,31 @@ __init int numa_setup(char *opt)
330 return 1; 330 return 1;
331} 331}
332 332
333/*
334 * Setup early cpu_to_node.
335 *
336 * Populate cpu_to_node[] only if x86_cpu_to_apicid[],
337 * and apicid_to_node[] tables have valid entries for a CPU.
338 * This means we skip cpu_to_node[] initialisation for NUMA
339 * emulation and faking node case (when running a kernel compiled
340 * for NUMA on a non NUMA box), which is OK as cpu_to_node[]
341 * is already initialized in a round robin manner at numa_init_array,
342 * prior to this call, and this initialization is good enough
343 * for the fake NUMA cases.
344 */
345void __init init_cpu_to_node(void)
346{
347 int i;
348 for (i = 0; i < NR_CPUS; i++) {
349 u8 apicid = x86_cpu_to_apicid[i];
350 if (apicid == BAD_APICID)
351 continue;
352 if (apicid_to_node[apicid] == NUMA_NO_NODE)
353 continue;
354 cpu_to_node[i] = apicid_to_node[apicid];
355 }
356}
357
333EXPORT_SYMBOL(cpu_to_node); 358EXPORT_SYMBOL(cpu_to_node);
334EXPORT_SYMBOL(node_to_cpumask); 359EXPORT_SYMBOL(node_to_cpumask);
335EXPORT_SYMBOL(memnode_shift); 360EXPORT_SYMBOL(memnode_shift);
diff --git a/include/asm-x86_64/numa.h b/include/asm-x86_64/numa.h
index d51e56fdc3da..34e434ce3268 100644
--- a/include/asm-x86_64/numa.h
+++ b/include/asm-x86_64/numa.h
@@ -20,6 +20,11 @@ extern int numa_off;
20extern void numa_set_node(int cpu, int node); 20extern void numa_set_node(int cpu, int node);
21 21
22extern unsigned char apicid_to_node[256]; 22extern unsigned char apicid_to_node[256];
23#ifdef CONFIG_NUMA
24extern void __init init_cpu_to_node(void);
25#else
26#define init_cpu_to_node() do {} while (0)
27#endif
23 28
24#define NUMA_NO_NODE 0xff 29#define NUMA_NO_NODE 0xff
25 30