diff options
Diffstat (limited to 'include/linux/topology.h')
| -rw-r--r-- | include/linux/topology.h | 109 |
1 files changed, 104 insertions, 5 deletions
diff --git a/include/linux/topology.h b/include/linux/topology.h index 5b81156780b1..64e084ff5e5c 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 |
| @@ -102,6 +103,7 @@ int arch_update_cpu_topology(void); | |||
| 102 | | 1*SD_SHARE_PKG_RESOURCES \ | 103 | | 1*SD_SHARE_PKG_RESOURCES \ |
| 103 | | 0*SD_SERIALIZE \ | 104 | | 0*SD_SERIALIZE \ |
| 104 | | 0*SD_PREFER_SIBLING \ | 105 | | 0*SD_PREFER_SIBLING \ |
| 106 | | arch_sd_sibling_asym_packing() \ | ||
| 105 | , \ | 107 | , \ |
| 106 | .last_balance = jiffies, \ | 108 | .last_balance = jiffies, \ |
| 107 | .balance_interval = 1, \ | 109 | .balance_interval = 1, \ |
| @@ -203,8 +205,110 @@ int arch_update_cpu_topology(void); | |||
| 203 | #ifndef SD_NODE_INIT | 205 | #ifndef SD_NODE_INIT |
| 204 | #error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!! | 206 | #error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!! |
| 205 | #endif | 207 | #endif |
| 208 | |||
| 206 | #endif /* CONFIG_NUMA */ | 209 | #endif /* CONFIG_NUMA */ |
| 207 | 210 | ||
| 211 | #ifdef CONFIG_USE_PERCPU_NUMA_NODE_ID | ||
| 212 | DECLARE_PER_CPU(int, numa_node); | ||
| 213 | |||
| 214 | #ifndef numa_node_id | ||
| 215 | /* Returns the number of the current Node. */ | ||
| 216 | static inline int numa_node_id(void) | ||
| 217 | { | ||
| 218 | return __this_cpu_read(numa_node); | ||
| 219 | } | ||
| 220 | #endif | ||
| 221 | |||
| 222 | #ifndef cpu_to_node | ||
| 223 | static inline int cpu_to_node(int cpu) | ||
| 224 | { | ||
| 225 | return per_cpu(numa_node, cpu); | ||
| 226 | } | ||
| 227 | #endif | ||
| 228 | |||
| 229 | #ifndef set_numa_node | ||
| 230 | static inline void set_numa_node(int node) | ||
| 231 | { | ||
| 232 | percpu_write(numa_node, node); | ||
| 233 | } | ||
| 234 | #endif | ||
| 235 | |||
| 236 | #ifndef set_cpu_numa_node | ||
| 237 | static inline void set_cpu_numa_node(int cpu, int node) | ||
| 238 | { | ||
| 239 | per_cpu(numa_node, cpu) = node; | ||
| 240 | } | ||
| 241 | #endif | ||
| 242 | |||
| 243 | #else /* !CONFIG_USE_PERCPU_NUMA_NODE_ID */ | ||
| 244 | |||
| 245 | /* Returns the number of the current Node. */ | ||
| 246 | #ifndef numa_node_id | ||
| 247 | static inline int numa_node_id(void) | ||
| 248 | { | ||
| 249 | return cpu_to_node(raw_smp_processor_id()); | ||
| 250 | } | ||
| 251 | #endif | ||
| 252 | |||
| 253 | #endif /* [!]CONFIG_USE_PERCPU_NUMA_NODE_ID */ | ||
| 254 | |||
| 255 | #ifdef CONFIG_HAVE_MEMORYLESS_NODES | ||
| 256 | |||
| 257 | /* | ||
| 258 | * N.B., Do NOT reference the '_numa_mem_' per cpu variable directly. | ||
| 259 | * It will not be defined when CONFIG_HAVE_MEMORYLESS_NODES is not defined. | ||
| 260 | * Use the accessor functions set_numa_mem(), numa_mem_id() and cpu_to_mem(). | ||
| 261 | */ | ||
| 262 | DECLARE_PER_CPU(int, _numa_mem_); | ||
| 263 | |||
| 264 | #ifndef set_numa_mem | ||
| 265 | static inline void set_numa_mem(int node) | ||
| 266 | { | ||
| 267 | percpu_write(_numa_mem_, node); | ||
| 268 | } | ||
| 269 | #endif | ||
| 270 | |||
| 271 | #ifndef numa_mem_id | ||
| 272 | /* Returns the number of the nearest Node with memory */ | ||
| 273 | static inline int numa_mem_id(void) | ||
| 274 | { | ||
| 275 | return __this_cpu_read(_numa_mem_); | ||
| 276 | } | ||
| 277 | #endif | ||
| 278 | |||
| 279 | #ifndef cpu_to_mem | ||
| 280 | static inline int cpu_to_mem(int cpu) | ||
| 281 | { | ||
| 282 | return per_cpu(_numa_mem_, cpu); | ||
| 283 | } | ||
| 284 | #endif | ||
| 285 | |||
| 286 | #ifndef set_cpu_numa_mem | ||
| 287 | static inline void set_cpu_numa_mem(int cpu, int node) | ||
| 288 | { | ||
| 289 | per_cpu(_numa_mem_, cpu) = node; | ||
| 290 | } | ||
| 291 | #endif | ||
| 292 | |||
| 293 | #else /* !CONFIG_HAVE_MEMORYLESS_NODES */ | ||
| 294 | |||
| 295 | #ifndef numa_mem_id | ||
| 296 | /* Returns the number of the nearest Node with memory */ | ||
| 297 | static inline int numa_mem_id(void) | ||
| 298 | { | ||
| 299 | return numa_node_id(); | ||
| 300 | } | ||
| 301 | #endif | ||
| 302 | |||
| 303 | #ifndef cpu_to_mem | ||
| 304 | static inline int cpu_to_mem(int cpu) | ||
| 305 | { | ||
| 306 | return cpu_to_node(cpu); | ||
| 307 | } | ||
| 308 | #endif | ||
| 309 | |||
| 310 | #endif /* [!]CONFIG_HAVE_MEMORYLESS_NODES */ | ||
| 311 | |||
| 208 | #ifndef topology_physical_package_id | 312 | #ifndef topology_physical_package_id |
| 209 | #define topology_physical_package_id(cpu) ((void)(cpu), -1) | 313 | #define topology_physical_package_id(cpu) ((void)(cpu), -1) |
| 210 | #endif | 314 | #endif |
| @@ -218,9 +322,4 @@ int arch_update_cpu_topology(void); | |||
| 218 | #define topology_core_cpumask(cpu) cpumask_of(cpu) | 322 | #define topology_core_cpumask(cpu) cpumask_of(cpu) |
| 219 | #endif | 323 | #endif |
| 220 | 324 | ||
| 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 */ | 325 | #endif /* _LINUX_TOPOLOGY_H */ |
