diff options
-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 | */ |