topology.h 3.2 KB

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