Signed-off-by: Andrew Morton --- arch/x86_64/kernel/setup.c | 23 ++++++++++++++--------- arch/x86_64/mm/numa.c | 3 +++ arch/x86_64/mm/srat.c | 17 +++-------------- include/asm-x86_64/numa.h | 2 ++ 4 files changed, 22 insertions(+), 23 deletions(-) diff -puN arch/x86_64/kernel/setup.c~x86_64-srat-apicid arch/x86_64/kernel/setup.c --- devel/arch/x86_64/kernel/setup.c~x86_64-srat-apicid 2005-09-07 19:46:18.000000000 -0700 +++ devel-akpm/arch/x86_64/kernel/setup.c 2005-09-07 19:46:18.000000000 -0700 @@ -765,6 +765,7 @@ static void __init amd_detect_cmp(struct int cpu = smp_processor_id(); int node = 0; unsigned bits; + unsigned apicid = phys_proc_id[cpu]; bits = 0; while ((1 << bits) < c->x86_num_cores) @@ -777,15 +778,19 @@ static void __init amd_detect_cmp(struct #ifdef CONFIG_NUMA /* When an ACPI SRAT table is available use the mappings from SRAT - instead. */ - if (acpi_numa <= 0) { - node = phys_proc_id[cpu]; - if (!node_online(node)) - node = first_node(node_online_map); - cpu_to_node[cpu] = node; - } else { - node = cpu_to_node[cpu]; - } + instead. */ + node = phys_proc_id[cpu]; + if (acpi_numa > 0) { + if (apicid_to_node[apicid] != NUMA_NO_NODE) + node = apicid_to_node[apicid]; + else + printk(KERN_ERR + "SRAT: Didn't specify node for CPU %d(%d)\n", + cpu, apicid); + } + if (!node_online(node)) + node = first_node(node_online_map); + cpu_to_node[cpu] = node; #endif printk(KERN_INFO "CPU %d(%d) -> Node %d -> Core %d\n", diff -puN arch/x86_64/mm/numa.c~x86_64-srat-apicid arch/x86_64/mm/numa.c --- devel/arch/x86_64/mm/numa.c~x86_64-srat-apicid 2005-09-07 19:46:18.000000000 -0700 +++ devel-akpm/arch/x86_64/mm/numa.c 2005-09-07 19:46:39.000000000 -0700 @@ -29,6 +29,9 @@ int memnode_shift; u8 memnodemap[NODEMAPSIZE]; unsigned char cpu_to_node[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = NUMA_NO_NODE }; +unsigned char apicid_to_node[256] __cpuinitdata = { + [0 ... NR_CPUS-1] = NUMA_NO_NODE +}; cpumask_t node_to_cpumask[MAX_NUMNODES] __read_mostly; int numa_off __initdata; diff -puN arch/x86_64/mm/srat.c~x86_64-srat-apicid arch/x86_64/mm/srat.c --- devel/arch/x86_64/mm/srat.c~x86_64-srat-apicid 2005-09-07 19:46:18.000000000 -0700 +++ devel-akpm/arch/x86_64/mm/srat.c 2005-09-07 19:46:18.000000000 -0700 @@ -20,9 +20,6 @@ static struct acpi_table_slit *acpi_slit; -/* Internal processor count */ -static unsigned int __initdata num_processors = 0; - static nodemask_t nodes_parsed __initdata; static nodemask_t nodes_found __initdata; static struct node nodes[MAX_NUMNODES] __initdata; @@ -104,18 +101,10 @@ acpi_numa_processor_affinity_init(struct bad_srat(); return; } - if (num_processors >= NR_CPUS) { - printk(KERN_ERR "SRAT: Processor #%d (lapic %u) INVALID. (Max ID: %d).\n", - num_processors, pa->apic_id, NR_CPUS); - bad_srat(); - return; - } - cpu_to_node[num_processors] = node; + apicid_to_node[pa->apic_id] = node; acpi_numa = 1; - printk(KERN_INFO "SRAT: PXM %u -> APIC %u -> CPU %u -> Node %u\n", - pxm, pa->apic_id, num_processors, node); - - num_processors++; + printk(KERN_INFO "SRAT: PXM %u -> APIC %u -> Node %u\n", + pxm, pa->apic_id, node); } /* Callback for parsing of the Proximity Domain <-> Memory Area mappings */ diff -puN include/asm-x86_64/numa.h~x86_64-srat-apicid include/asm-x86_64/numa.h --- devel/include/asm-x86_64/numa.h~x86_64-srat-apicid 2005-09-07 19:46:18.000000000 -0700 +++ devel-akpm/include/asm-x86_64/numa.h 2005-09-07 19:46:18.000000000 -0700 @@ -16,6 +16,8 @@ extern void numa_add_cpu(int cpu); extern void numa_init_array(void); extern int numa_off; +extern unsigned char apicid_to_node[256]; + #define NUMA_NO_NODE 0xff #endif _