aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/topology.h
diff options
context:
space:
mode:
authorLee Schermerhorn <lee.schermerhorn@hp.com>2010-05-26 17:44:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-27 12:12:57 -0400
commit7281201922a0063fa60804ce39c277fc98142a47 (patch)
tree4bf089d077b1055e54bc1411dcc0db121d01d9fa /include/linux/topology.h
parent866707fc2721df8fee637fcf0239628b9231f9ea (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>
Diffstat (limited to 'include/linux/topology.h')
-rw-r--r--include/linux/topology.h51
1 files changed, 46 insertions, 5 deletions
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
211DECLARE_PER_CPU(int, numa_node);
212
213#ifndef numa_node_id
214/* Returns the number of the current Node. */
215static inline int numa_node_id(void)
216{
217 return __this_cpu_read(numa_node);
218}
219#endif
220
221#ifndef cpu_to_node
222static inline int cpu_to_node(int cpu)
223{
224 return per_cpu(numa_node, cpu);
225}
226#endif
227
228#ifndef set_numa_node
229static inline void set_numa_node(int node)
230{
231 percpu_write(numa_node, node);
232}
233#endif
234
235#ifndef set_cpu_numa_node
236static 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
246static 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 */