diff options
Diffstat (limited to 'include/linux/topology.h')
-rw-r--r-- | include/linux/topology.h | 51 |
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 | ||
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 */ |