diff options
Diffstat (limited to 'include/linux/topology.h')
-rw-r--r-- | include/linux/topology.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/include/linux/topology.h b/include/linux/topology.h index 2e5518f46571..c44df50a05ab 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h | |||
@@ -251,6 +251,67 @@ static inline int numa_node_id(void) | |||
251 | 251 | ||
252 | #endif /* [!]CONFIG_USE_PERCPU_NUMA_NODE_ID */ | 252 | #endif /* [!]CONFIG_USE_PERCPU_NUMA_NODE_ID */ |
253 | 253 | ||
254 | #ifdef CONFIG_HAVE_MEMORYLESS_NODES | ||
255 | |||
256 | /* | ||
257 | * N.B., Do NOT reference the '_numa_mem_' per cpu variable directly. | ||
258 | * It will not be defined when CONFIG_HAVE_MEMORYLESS_NODES is not defined. | ||
259 | * Use the accessor functions set_numa_mem(), numa_mem_id() and cpu_to_mem(). | ||
260 | */ | ||
261 | DECLARE_PER_CPU(int, _numa_mem_); | ||
262 | |||
263 | #ifndef set_numa_mem | ||
264 | static inline void set_numa_mem(int node) | ||
265 | { | ||
266 | percpu_write(_numa_mem_, node); | ||
267 | } | ||
268 | #endif | ||
269 | |||
270 | #ifndef numa_mem_id | ||
271 | /* Returns the number of the nearest Node with memory */ | ||
272 | static inline int numa_mem_id(void) | ||
273 | { | ||
274 | return __this_cpu_read(_numa_mem_); | ||
275 | } | ||
276 | #endif | ||
277 | |||
278 | #ifndef cpu_to_mem | ||
279 | static inline int cpu_to_mem(int cpu) | ||
280 | { | ||
281 | return per_cpu(_numa_mem_, cpu); | ||
282 | } | ||
283 | #endif | ||
284 | |||
285 | #ifndef set_cpu_numa_mem | ||
286 | static inline void set_cpu_numa_mem(int cpu, int node) | ||
287 | { | ||
288 | per_cpu(_numa_mem_, cpu) = node; | ||
289 | } | ||
290 | #endif | ||
291 | |||
292 | #else /* !CONFIG_HAVE_MEMORYLESS_NODES */ | ||
293 | |||
294 | static inline void set_numa_mem(int node) {} | ||
295 | |||
296 | static inline void set_cpu_numa_mem(int cpu, int node) {} | ||
297 | |||
298 | #ifndef numa_mem_id | ||
299 | /* Returns the number of the nearest Node with memory */ | ||
300 | static inline int numa_mem_id(void) | ||
301 | { | ||
302 | return numa_node_id(); | ||
303 | } | ||
304 | #endif | ||
305 | |||
306 | #ifndef cpu_to_mem | ||
307 | static inline int cpu_to_mem(int cpu) | ||
308 | { | ||
309 | return cpu_to_node(cpu); | ||
310 | } | ||
311 | #endif | ||
312 | |||
313 | #endif /* [!]CONFIG_HAVE_MEMORYLESS_NODES */ | ||
314 | |||
254 | #ifndef topology_physical_package_id | 315 | #ifndef topology_physical_package_id |
255 | #define topology_physical_package_id(cpu) ((void)(cpu), -1) | 316 | #define topology_physical_package_id(cpu) ((void)(cpu), -1) |
256 | #endif | 317 | #endif |