topology.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #ifndef _ASM_POWERPC_TOPOLOGY_H
  2. #define _ASM_POWERPC_TOPOLOGY_H
  3. #ifdef __KERNEL__
  4. struct device;
  5. struct device_node;
  6. #ifdef CONFIG_NUMA
  7. /*
  8. * Before going off node we want the VM to try and reclaim from the local
  9. * node. It does this if the remote distance is larger than RECLAIM_DISTANCE.
  10. * With the default REMOTE_DISTANCE of 20 and the default RECLAIM_DISTANCE of
  11. * 20, we never reclaim and go off node straight away.
  12. *
  13. * To fix this we choose a smaller value of RECLAIM_DISTANCE.
  14. */
  15. #define RECLAIM_DISTANCE 10
  16. /*
  17. * Avoid creating an extra level of balancing (SD_ALLNODES) on the largest
  18. * POWER7 boxes which have a maximum of 32 nodes.
  19. */
  20. #define SD_NODES_PER_DOMAIN 32
  21. #include <asm/mmzone.h>
  22. static inline int cpu_to_node(int cpu)
  23. {
  24. return numa_cpu_lookup_table[cpu];
  25. }
  26. #define parent_node(node) (node)
  27. #define cpumask_of_node(node) ((node) == -1 ? \
  28. cpu_all_mask : \
  29. node_to_cpumask_map[node])
  30. struct pci_bus;
  31. #ifdef CONFIG_PCI
  32. extern int pcibus_to_node(struct pci_bus *bus);
  33. #else
  34. static inline int pcibus_to_node(struct pci_bus *bus)
  35. {
  36. return -1;
  37. }
  38. #endif
  39. #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
  40. cpu_all_mask : \
  41. cpumask_of_node(pcibus_to_node(bus)))
  42. /* sched_domains SD_NODE_INIT for PPC64 machines */
  43. #define SD_NODE_INIT (struct sched_domain) { \
  44. .min_interval = 8, \
  45. .max_interval = 32, \
  46. .busy_factor = 32, \
  47. .imbalance_pct = 125, \
  48. .cache_nice_tries = 1, \
  49. .busy_idx = 3, \
  50. .idle_idx = 1, \
  51. .newidle_idx = 0, \
  52. .wake_idx = 0, \
  53. .forkexec_idx = 0, \
  54. \
  55. .flags = 1*SD_LOAD_BALANCE \
  56. | 0*SD_BALANCE_NEWIDLE \
  57. | 1*SD_BALANCE_EXEC \
  58. | 1*SD_BALANCE_FORK \
  59. | 0*SD_BALANCE_WAKE \
  60. | 1*SD_WAKE_AFFINE \
  61. | 0*SD_PREFER_LOCAL \
  62. | 0*SD_SHARE_CPUPOWER \
  63. | 0*SD_POWERSAVINGS_BALANCE \
  64. | 0*SD_SHARE_PKG_RESOURCES \
  65. | 1*SD_SERIALIZE \
  66. | 0*SD_PREFER_SIBLING \
  67. , \
  68. .last_balance = jiffies, \
  69. .balance_interval = 1, \
  70. }
  71. extern int __node_distance(int, int);
  72. #define node_distance(a, b) __node_distance(a, b)
  73. extern void __init dump_numa_cpu_topology(void);
  74. extern int sysfs_add_device_to_node(struct device *dev, int nid);
  75. extern void sysfs_remove_device_from_node(struct device *dev, int nid);
  76. #else
  77. static inline void dump_numa_cpu_topology(void) {}
  78. static inline int sysfs_add_device_to_node(struct device *dev, int nid)
  79. {
  80. return 0;
  81. }
  82. static inline void sysfs_remove_device_from_node(struct device *dev,
  83. int nid)
  84. {
  85. }
  86. #endif /* CONFIG_NUMA */
  87. #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
  88. extern int start_topology_update(void);
  89. extern int stop_topology_update(void);
  90. #else
  91. static inline int start_topology_update(void)
  92. {
  93. return 0;
  94. }
  95. static inline int stop_topology_update(void)
  96. {
  97. return 0;
  98. }
  99. #endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
  100. #include <asm-generic/topology.h>
  101. #ifdef CONFIG_SMP
  102. #include <asm/cputable.h>
  103. #define smt_capable() (cpu_has_feature(CPU_FTR_SMT))
  104. #ifdef CONFIG_PPC64
  105. #include <asm/smp.h>
  106. #define topology_thread_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
  107. #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
  108. #define topology_core_id(cpu) (cpu_to_core_id(cpu))
  109. #endif
  110. #endif
  111. #endif /* __KERNEL__ */
  112. #endif /* _ASM_POWERPC_TOPOLOGY_H */