--- arch/x86/include/asm/topology.h | 13 +------------ include/linux/topology.h | 15 ++++++++++++--- mm/percpu.c | 14 +++++++++++++- 3 files changed, 26 insertions(+), 16 deletions(-) Index: linux-2.6/arch/x86/include/asm/topology.h =================================================================== --- linux-2.6.orig/arch/x86/include/asm/topology.h 2009-10-30 11:48:28.000000000 -0500 +++ linux-2.6/arch/x86/include/asm/topology.h 2009-10-30 11:50:29.000000000 -0500 @@ -48,33 +48,22 @@ extern int cpu_to_node_map[]; /* Returns the number of the node containing CPU 'cpu' */ -static inline int cpu_to_node(int cpu) +static inline int early_cpu_to_node(int cpu) { return cpu_to_node_map[cpu]; } -#define early_cpu_to_node(cpu) cpu_to_node(cpu) #else /* CONFIG_X86_64 */ /* Mappings between logical cpu number and node number */ DECLARE_EARLY_PER_CPU(int, x86_cpu_to_node_map); -/* Returns the number of the current Node. */ -DECLARE_PER_CPU(int, node_number); -#define numa_node_id() percpu_read(node_number) - #ifdef CONFIG_DEBUG_PER_CPU_MAPS extern int cpu_to_node(int cpu); extern int early_cpu_to_node(int cpu); #else /* !CONFIG_DEBUG_PER_CPU_MAPS */ -/* Returns the number of the node containing CPU 'cpu' */ -static inline int cpu_to_node(int cpu) -{ - return per_cpu(x86_cpu_to_node_map, cpu); -} - /* Same function but used if called before per_cpu areas are setup */ static inline int early_cpu_to_node(int cpu) { Index: linux-2.6/include/linux/topology.h =================================================================== --- linux-2.6.orig/include/linux/topology.h 2009-10-30 11:43:33.000000000 -0500 +++ linux-2.6/include/linux/topology.h 2009-10-30 11:48:16.000000000 -0500 @@ -218,9 +218,18 @@ int arch_update_cpu_topology(void); #define topology_core_cpumask(cpu) cpumask_of(cpu) #endif -/* Returns the number of the current Node. */ -#ifndef numa_node_id -#define numa_node_id() (cpu_to_node(raw_smp_processor_id())) +DECLARE_PER_CPU(numa_node) +#ifdef CONFIG_NUMA_HOTPLUG +DECLARE_PER_CPU(numa_mem) +#else +#define numa_mem numa_node #endif +/* Returns the number of the current Node. */ +#define numa_node_id() __this_cpu_read(numa_node) +#define numa_mem_id() __this_cpu_read(numa_mem) + +#define cpu_to_node(__cpu) percpu(numa_node, (__cpu)) +#define cpu_to_mem(__cpu) percpu(numa_mem, (__cpu)) + #endif /* _LINUX_TOPOLOGY_H */ Index: linux-2.6/mm/percpu.c =================================================================== --- linux-2.6.orig/mm/percpu.c 2009-10-30 11:42:01.000000000 -0500 +++ linux-2.6/mm/percpu.c 2009-10-30 11:43:27.000000000 -0500 @@ -2025,7 +2025,8 @@ out_free_ar: * Generic percpu area setup. * * The embedding helper is used because its behavior closely resembles - * the original non-dynamic generic percpu area setup. This is + +* the original non-dynamic generic percpu area setup. This is * important because many archs have addressing restrictions and might * fail if the percpu area is located far away from the previous * location. As an added bonus, in non-NUMA cases, embedding is @@ -2069,3 +2070,14 @@ void __init setup_per_cpu_areas(void) __per_cpu_offset[cpu] = delta + pcpu_unit_offsets[cpu]; } #endif /* CONFIG_HAVE_SETUP_PER_CPU_AREA */ + +/* NUMA Setup */ + +#ifdef CONFIG_NUMA +DEFINE_PER_CPU(numa_node); + +#ifdef CONFIG_MEMORY_HOTPLUG +DEFINE_PER_CPU(numa_mem); +#endif +#endif +