diff options
author | Lee Schermerhorn <lee.schermerhorn@hp.com> | 2010-05-26 17:44:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 12:12:57 -0400 |
commit | 7281201922a0063fa60804ce39c277fc98142a47 (patch) | |
tree | 4bf089d077b1055e54bc1411dcc0db121d01d9fa | |
parent | 866707fc2721df8fee637fcf0239628b9231f9ea (diff) |
numa: add generic percpu var numa_node_id() implementation
Rework the generic version of the numa_node_id() function to use the new
generic percpu variable infrastructure.
Guard the new implementation with a new config option:
CONFIG_USE_PERCPU_NUMA_NODE_ID.
Archs which support this new implemention will default this option to 'y'
when NUMA is configured. This config option could be removed if/when all
archs switch over to the generic percpu implementation of numa_node_id().
Arch support involves:
1) converting any existing per cpu variable implementations to use
this implementation. x86_64 is an instance of such an arch.
2) archs that don't use a per cpu variable for numa_node_id() will
need to initialize the new per cpu variable "numa_node" as cpus
are brought on-line. ia64 is an example.
3) Defining USE_PERCPU_NUMA_NODE_ID in arch dependent Kconfig--e.g.,
when NUMA is configured. This is required because I have
retained the old implementation by default to allow archs to
be modified incrementally, as desired.
Subsequent patches will convert x86_64 and ia64 to use this implemenation.
Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Mel Gorman <mel@csn.ul.ie>
Reviewed-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Nick Piggin <npiggin@suse.de>
Cc: David Rientjes <rientjes@google.com>
Cc: Eric Whitney <eric.whitney@hp.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/x86/include/asm/topology.h | 4 | ||||
-rw-r--r-- | include/linux/topology.h | 51 | ||||
-rw-r--r-- | mm/page_alloc.c | 5 |
3 files changed, 55 insertions, 5 deletions
diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h index c5087d796587..a2e629476b0e 100644 --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h | |||
@@ -170,6 +170,10 @@ static inline int numa_node_id(void) | |||
170 | { | 170 | { |
171 | return 0; | 171 | return 0; |
172 | } | 172 | } |
173 | /* | ||
174 | * indicate override: | ||
175 | */ | ||
176 | #define numa_node_id numa_node_id | ||
173 | 177 | ||
174 | static inline int early_cpu_to_node(int cpu) | 178 | static inline int early_cpu_to_node(int cpu) |
175 | { | 179 | { |
diff --git a/include/linux/topology.h b/include/linux/topology.h index 5b81156780b1..2e5518f46571 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/bitops.h> | 31 | #include <linux/bitops.h> |
32 | #include <linux/mmzone.h> | 32 | #include <linux/mmzone.h> |
33 | #include <linux/smp.h> | 33 | #include <linux/smp.h> |
34 | #include <linux/percpu.h> | ||
34 | #include <asm/topology.h> | 35 | #include <asm/topology.h> |
35 | 36 | ||
36 | #ifndef node_has_online_mem | 37 | #ifndef node_has_online_mem |
@@ -203,8 +204,53 @@ int arch_update_cpu_topology(void); | |||
203 | #ifndef SD_NODE_INIT | 204 | #ifndef SD_NODE_INIT |
204 | #error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!! | 205 | #error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!! |
205 | #endif | 206 | #endif |
207 | |||
206 | #endif /* CONFIG_NUMA */ | 208 | #endif /* CONFIG_NUMA */ |
207 | 209 | ||
210 | #ifdef CONFIG_USE_PERCPU_NUMA_NODE_ID | ||
211 | DECLARE_PER_CPU(int, numa_node); | ||
212 | |||
213 | #ifndef numa_node_id | ||
214 | /* Returns the number of the current Node. */ | ||
215 | static inline int numa_node_id(void) | ||
216 | { | ||
217 | return __this_cpu_read(numa_node); | ||
218 | } | ||
219 | #endif | ||
220 | |||
221 | #ifndef cpu_to_node | ||
222 | static inline int cpu_to_node(int cpu) | ||
223 | { | ||
224 | return per_cpu(numa_node, cpu); | ||
225 | } | ||
226 | #endif | ||
227 | |||
228 | #ifndef set_numa_node | ||
229 | static inline void set_numa_node(int node) | ||
230 | { | ||
231 | percpu_write(numa_node, node); | ||
232 | } | ||
233 | #endif | ||
234 | |||
235 | #ifndef set_cpu_numa_node | ||
236 | static inline void set_cpu_numa_node(int cpu, int node) | ||
237 | { | ||
238 | per_cpu(numa_node, cpu) = node; | ||
239 | } | ||
240 | #endif | ||
241 | |||
242 | #else /* !CONFIG_USE_PERCPU_NUMA_NODE_ID */ | ||
243 | |||
244 | /* Returns the number of the current Node. */ | ||
245 | #ifndef numa_node_id | ||
246 | static inline int numa_node_id(void) | ||
247 | { | ||
248 | return cpu_to_node(raw_smp_processor_id()); | ||
249 | } | ||
250 | #endif | ||
251 | |||
252 | #endif /* [!]CONFIG_USE_PERCPU_NUMA_NODE_ID */ | ||
253 | |||
208 | #ifndef topology_physical_package_id | 254 | #ifndef topology_physical_package_id |
209 | #define topology_physical_package_id(cpu) ((void)(cpu), -1) | 255 | #define topology_physical_package_id(cpu) ((void)(cpu), -1) |
210 | #endif | 256 | #endif |
@@ -218,9 +264,4 @@ int arch_update_cpu_topology(void); | |||
218 | #define topology_core_cpumask(cpu) cpumask_of(cpu) | 264 | #define topology_core_cpumask(cpu) cpumask_of(cpu) |
219 | #endif | 265 | #endif |
220 | 266 | ||
221 | /* Returns the number of the current Node. */ | ||
222 | #ifndef numa_node_id | ||
223 | #define numa_node_id() (cpu_to_node(raw_smp_processor_id())) | ||
224 | #endif | ||
225 | |||
226 | #endif /* _LINUX_TOPOLOGY_H */ | 267 | #endif /* _LINUX_TOPOLOGY_H */ |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 08b349931ebc..6fe1b65ee1a8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -57,6 +57,11 @@ | |||
57 | #include <asm/div64.h> | 57 | #include <asm/div64.h> |
58 | #include "internal.h" | 58 | #include "internal.h" |
59 | 59 | ||
60 | #ifdef CONFIG_USE_PERCPU_NUMA_NODE_ID | ||
61 | DEFINE_PER_CPU(int, numa_node); | ||
62 | EXPORT_PER_CPU_SYMBOL(numa_node); | ||
63 | #endif | ||
64 | |||
60 | /* | 65 | /* |
61 | * Array of node states. | 66 | * Array of node states. |
62 | */ | 67 | */ |