topology.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef _ASM_POWERPC_TOPOLOGY_H
  2. #define _ASM_POWERPC_TOPOLOGY_H
  3. #ifdef __KERNEL__
  4. struct sys_device;
  5. struct device_node;
  6. #ifdef CONFIG_NUMA
  7. #include <asm/mmzone.h>
  8. static inline int cpu_to_node(int cpu)
  9. {
  10. return numa_cpu_lookup_table[cpu];
  11. }
  12. #define parent_node(node) (node)
  13. static inline cpumask_t node_to_cpumask(int node)
  14. {
  15. return numa_cpumask_lookup_table[node];
  16. }
  17. #define cpumask_of_node(node) (&numa_cpumask_lookup_table[node])
  18. static inline int node_to_first_cpu(int node)
  19. {
  20. return cpumask_first(cpumask_of_node(node));
  21. }
  22. int of_node_to_nid(struct device_node *device);
  23. struct pci_bus;
  24. #ifdef CONFIG_PCI
  25. extern int pcibus_to_node(struct pci_bus *bus);
  26. #else
  27. static inline int pcibus_to_node(struct pci_bus *bus)
  28. {
  29. return -1;
  30. }
  31. #endif
  32. #define pcibus_to_cpumask(bus) (pcibus_to_node(bus) == -1 ? \
  33. CPU_MASK_ALL : \
  34. node_to_cpumask(pcibus_to_node(bus)) \
  35. )
  36. #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
  37. cpu_all_mask : \
  38. cpumask_of_node(pcibus_to_node(bus)))
  39. /* sched_domains SD_NODE_INIT for PPC64 machines */
  40. #define SD_NODE_INIT (struct sched_domain) { \
  41. .span = CPU_MASK_NONE, \
  42. .parent = NULL, \
  43. .child = NULL, \
  44. .groups = NULL, \
  45. .min_interval = 8, \
  46. .max_interval = 32, \
  47. .busy_factor = 32, \
  48. .imbalance_pct = 125, \
  49. .cache_nice_tries = 1, \
  50. .busy_idx = 3, \
  51. .idle_idx = 1, \
  52. .newidle_idx = 2, \
  53. .wake_idx = 1, \
  54. .flags = SD_LOAD_BALANCE \
  55. | SD_BALANCE_EXEC \
  56. | SD_BALANCE_NEWIDLE \
  57. | SD_WAKE_IDLE \
  58. | SD_SERIALIZE \
  59. | SD_WAKE_BALANCE, \
  60. .last_balance = jiffies, \
  61. .balance_interval = 1, \
  62. .nr_balance_failed = 0, \
  63. }
  64. extern void __init dump_numa_cpu_topology(void);
  65. extern int sysfs_add_device_to_node(struct sys_device *dev, int nid);
  66. extern void sysfs_remove_device_from_node(struct sys_device *dev, int nid);
  67. #else
  68. static inline int of_node_to_nid(struct device_node *device)
  69. {
  70. return 0;
  71. }
  72. static inline void dump_numa_cpu_topology(void) {}
  73. static inline int sysfs_add_device_to_node(struct sys_device *dev, int nid)
  74. {
  75. return 0;
  76. }
  77. static inline void sysfs_remove_device_from_node(struct sys_device *dev,
  78. int nid)
  79. {
  80. }
  81. #endif /* CONFIG_NUMA */
  82. #include <asm-generic/topology.h>
  83. #ifdef CONFIG_SMP
  84. #include <asm/cputable.h>
  85. #define smt_capable() (cpu_has_feature(CPU_FTR_SMT))
  86. #ifdef CONFIG_PPC64
  87. #include <asm/smp.h>
  88. #define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))
  89. #define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu))
  90. #define topology_core_id(cpu) (cpu_to_core_id(cpu))
  91. #endif
  92. #endif
  93. #endif /* __KERNEL__ */
  94. #endif /* _ASM_POWERPC_TOPOLOGY_H */