From: Yasunori Goto In current code, i386, x86-64, and ia64 have separate code. But PXM is defined by ACPI and node id is used generically. So, I think there is no reason to define it on each arch's code. This mapping should be written at drivers/acpi/numa.c as a common code. This is new generic code for pxm_to_node_map. Signed-off-by: Yasunori Goto Cc: "Luck, Tony" Cc: Andi Kleen Cc: "Brown, Len" Signed-off-by: Andrew Morton --- drivers/acpi/numa.c | 50 +++++++++++++++++++++++++++++++++++++ include/acpi/acpi_numa.h | 18 +++++++++++++ include/linux/acpi.h | 1 3 files changed, 69 insertions(+) diff -puN drivers/acpi/numa.c~unify-pxm_to_node-id-ver2-generic-code drivers/acpi/numa.c --- 25/drivers/acpi/numa.c~unify-pxm_to_node-id-ver2-generic-code Thu Feb 2 15:27:50 2006 +++ 25-akpm/drivers/acpi/numa.c Thu Feb 2 15:27:50 2006 @@ -36,12 +36,62 @@ #define _COMPONENT ACPI_NUMA ACPI_MODULE_NAME("numa") +static nodemask_t nodes_found_map = NODE_MASK_NONE; +#define PXM_INVAL 0xff +#define NID_INVAL 0xff + +/* maps to convert between proximity domain and logical node ID */ +u8 __cpuinitdata pxm_to_node_map[MAX_PXM_DOMAINS] + = { [0 ... MAX_PXM_DOMAINS - 1] = NID_INVAL }; +u8 __cpuinitdata node_to_pxm_map[MAX_NUMNODES] + = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL }; + extern int __init acpi_table_parse_madt_family(enum acpi_table_id id, unsigned long madt_size, int entry_id, acpi_madt_entry_handler handler, unsigned int max_entries); +int __cpuinit pxm_to_node(int pxm) +{ + if ((unsigned)pxm >= 256) + return -1; + /* Extent 0xff to (int)-1 */ + return (signed char)pxm_to_node_map[pxm]; +} + +int __cpuinit node_to_pxm(int node) +{ + if ((unsigned)node >= 256) + return -1; + /* Extent 0xff to (int)-1 */ + return (signed char)node_to_pxm_map[node]; +} + +int __cpuinit acpi_map_pxm_to_node(u8 pxm) +{ + u8 node = pxm_to_node_map[pxm]; + + if (node == NID_INVAL){ + if (nodes_weight(nodes_found_map) >= MAX_NUMNODES) + return -1; + node = first_unset_node(nodes_found_map); + pxm_to_node_map[pxm] = node; + node_to_pxm_map[node] = pxm; + node_set(node, nodes_found_map); + } + + return (int)node; +} + +void __cpuinit acpi_unmap_pxm_to_node(int node) +{ + u8 pxm = node_to_pxm_map[node]; + pxm_to_node_map[pxm] = NID_INVAL; + node_to_pxm_map[node] = PXM_INVAL; + node_clear(node, nodes_found_map); +} + void __init acpi_table_print_srat_entry(acpi_table_entry_header * header) { diff -puN /dev/null include/acpi/acpi_numa.h --- /dev/null Thu Apr 11 07:25:15 2002 +++ 25-akpm/include/acpi/acpi_numa.h Thu Feb 2 15:27:50 2006 @@ -0,0 +1,18 @@ +#ifndef __ACPI_NUMA_H +#define __ACPI_NUMA_H + +#ifdef CONFIG_ACPI_NUMA +#include + +/* Proximity bitmap length; _PXM is at most 255 (8 bit)*/ +#define MAX_PXM_DOMAINS (256) +extern u8 __cpuinitdata pxm_to_node_map[MAX_PXM_DOMAINS]; +extern u8 __cpuinitdata node_to_pxm_map[MAX_NUMNODES]; + +extern int __cpuinit pxm_to_node(int); +extern int __cpuinit node_to_pxm(int); +extern int __cpuinit acpi_map_pxm_to_node(u8); +extern void __cpuinit acpi_unmap_pxm_to_node(int); + +#endif /* CONFIG_ACPI_NUMA */ +#endif /* __ACP_NUMA_H */ diff -puN include/linux/acpi.h~unify-pxm_to_node-id-ver2-generic-code include/linux/acpi.h --- 25/include/linux/acpi.h~unify-pxm_to_node-id-ver2-generic-code Thu Feb 2 15:27:50 2006 +++ 25-akpm/include/linux/acpi.h Thu Feb 2 15:27:50 2006 @@ -38,6 +38,7 @@ #include #include #include +#include #include _