Commit aa6b54461cc5c0019b9d792adf3176b444c10763

Authored by Mike Travis
Committed by Ingo Molnar
1 parent d18d00f5db

asm-generic: add node_to_cpumask_ptr macro

Create a simple macro to always return a pointer to the node_to_cpumask(node)
value.  This relies on compiler optimization to remove the extra indirection:

    #define node_to_cpumask_ptr(v, node) 		\
	    cpumask_t _##v = node_to_cpumask(node), *v = &_##v

For those systems with a large cpumask size, then a true pointer
to the array element can be used:

    #define node_to_cpumask_ptr(v, node)		\
	    cpumask_t *v = &(node_to_cpumask_map[node])

A node_to_cpumask_ptr_next() macro is provided to access another
node_to_cpumask value.

The other change is to always include asm-generic/topology.h moving the
ifdef CONFIG_NUMA to this same file.

Note: there are no references to either of these new macros in this patch,
only the definition.

Based on 2.6.25-rc5-mm1

# alpha
Cc: Richard Henderson <rth@twiddle.net>

# fujitsu
Cc: David Howells <dhowells@redhat.com>

# ia64
Cc: Tony Luck <tony.luck@intel.com>

# powerpc
Cc: Paul Mackerras <paulus@samba.org>
Cc: Anton Blanchard <anton@samba.org>

# sparc
Cc: David S. Miller <davem@davemloft.net>
Cc: William L. Irwin <wli@holomorphy.com>

# x86
Cc: H. Peter Anvin <hpa@zytor.com>

Signed-off-by: Mike Travis <travis@sgi.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 6 changed files with 35 additions and 9 deletions Side-by-side Diff

include/asm-alpha/topology.h
... ... @@ -41,9 +41,8 @@
41 41  
42 42 #define pcibus_to_cpumask(bus) (cpu_online_map)
43 43  
44   -#else /* CONFIG_NUMA */
45   -# include <asm-generic/topology.h>
46 44 #endif /* !CONFIG_NUMA */
  45 +# include <asm-generic/topology.h>
47 46  
48 47 #endif /* _ASM_ALPHA_TOPOLOGY_H */
include/asm-frv/topology.h
... ... @@ -5,11 +5,9 @@
5 5  
6 6 #error NUMA not supported yet
7 7  
8   -#else /* !CONFIG_NUMA */
  8 +#endif /* CONFIG_NUMA */
9 9  
10 10 #include <asm-generic/topology.h>
11   -
12   -#endif /* CONFIG_NUMA */
13 11  
14 12 #endif /* _ASM_TOPOLOGY_H */
include/asm-generic/topology.h
... ... @@ -27,6 +27,8 @@
27 27 #ifndef _ASM_GENERIC_TOPOLOGY_H
28 28 #define _ASM_GENERIC_TOPOLOGY_H
29 29  
  30 +#ifndef CONFIG_NUMA
  31 +
30 32 /* Other architectures wishing to use this simple topology API should fill
31 33 in the below functions as appropriate in their own <asm/topology.h> file. */
32 34 #ifndef cpu_to_node
... ... @@ -50,6 +52,18 @@
50 52 CPU_MASK_ALL : \
51 53 node_to_cpumask(pcibus_to_node(bus)) \
52 54 )
  55 +#endif
  56 +
  57 +#endif /* CONFIG_NUMA */
  58 +
  59 +/* returns pointer to cpumask for specified node */
  60 +#ifndef node_to_cpumask_ptr
  61 +
  62 +#define node_to_cpumask_ptr(v, node) \
  63 + cpumask_t _##v = node_to_cpumask(node), *v = &_##v
  64 +
  65 +#define node_to_cpumask_ptr_next(v, node) \
  66 + _##v = node_to_cpumask(node)
53 67 #endif
54 68  
55 69 #endif /* _ASM_GENERIC_TOPOLOGY_H */
include/asm-ia64/topology.h
... ... @@ -116,6 +116,11 @@
116 116 #define smt_capable() (smp_num_siblings > 1)
117 117 #endif
118 118  
  119 +#define pcibus_to_cpumask(bus) (pcibus_to_node(bus) == -1 ? \
  120 + CPU_MASK_ALL : \
  121 + node_to_cpumask(pcibus_to_node(bus)) \
  122 + )
  123 +
119 124 #include <asm-generic/topology.h>
120 125  
121 126 #endif /* _ASM_IA64_TOPOLOGY_H */
include/asm-powerpc/topology.h
... ... @@ -96,10 +96,9 @@
96 96 {
97 97 }
98 98  
  99 +#endif /* CONFIG_NUMA */
99 100  
100 101 #include <asm-generic/topology.h>
101   -
102   -#endif /* CONFIG_NUMA */
103 102  
104 103 #ifdef CONFIG_SMP
105 104 #include <asm/cputable.h>
include/asm-x86/topology.h
... ... @@ -88,6 +88,17 @@
88 88 #endif
89 89 return per_cpu(x86_cpu_to_node_map, cpu);
90 90 }
  91 +
  92 +#ifdef CONFIG_NUMA
  93 +
  94 +/* Returns a pointer to the cpumask of CPUs on Node 'node'. */
  95 +#define node_to_cpumask_ptr(v, node) \
  96 + cpumask_t *v = &(node_to_cpumask_map[node])
  97 +
  98 +#define node_to_cpumask_ptr_next(v, node) \
  99 + v = &(node_to_cpumask_map[node])
  100 +#endif
  101 +
91 102 #endif /* CONFIG_X86_64 */
92 103  
93 104 /*
94 105  
... ... @@ -174,9 +185,9 @@
174 185  
175 186 #else /* CONFIG_NUMA */
176 187  
177   -#include <asm-generic/topology.h>
178   -
179 188 #endif
  189 +
  190 +#include <asm-generic/topology.h>
180 191  
181 192 extern cpumask_t cpu_coregroup_map(int cpu);
182 193