topology.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. int of_node_to_nid(struct device_node *device);
  19. struct pci_bus;
  20. #ifdef CONFIG_PCI
  21. extern int pcibus_to_node(struct pci_bus *bus);
  22. #else
  23. static inline int pcibus_to_node(struct pci_bus *bus)
  24. {
  25. return -1;
  26. }
  27. #endif
  28. #define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \
  29. cpu_all_mask : \
  30. cpumask_of_node(pcibus_to_node(bus)))
  31. /* sched_domains SD_NODE_INIT for PPC64 machines */
  32. #define SD_NODE_INIT (struct sched_domain) { \
  33. .parent = NULL, \
  34. .child = NULL, \
  35. .groups = NULL, \
  36. .min_interval = 8, \
  37. .max_interval = 32, \
  38. .busy_factor = 32, \
  39. .imbalance_pct = 125, \
  40. .cache_nice_tries = 1, \
  41. .busy_idx = 3, \
  42. .idle_idx = 1, \
  43. .newidle_idx = 0, \
  44. .wake_idx = 0, \
  45. .flags = SD_LOAD_BALANCE \
  46. | SD_BALANCE_EXEC \
  47. | SD_BALANCE_FORK \
  48. | SD_BALANCE_NEWIDLE \
  49. | SD_SERIALIZE, \
  50. .last_balance = jiffies, \
  51. .balance_interval = 1, \
  52. .nr_balance_failed = 0, \
  53. }
  54. extern void __init dump_numa_cpu_topology(void);
  55. extern int sysfs_add_device_to_node(struct sys_device *dev, int nid);
  56. extern void sysfs_remove_device_from_node(struct sys_device *dev, int nid);
  57. #else
  58. static inline int of_node_to_nid(struct device_node *device)
  59. {
  60. return 0;
  61. }
  62. static inline void dump_numa_cpu_topology(void) {}
  63. static inline int sysfs_add_device_to_node(struct sys_device *dev, int nid)
  64. {
  65. return 0;
  66. }
  67. static inline void sysfs_remove_device_from_node(struct sys_device *dev,
  68. int nid)
  69. {
  70. }
  71. #endif /* CONFIG_NUMA */
  72. #include <asm-generic/topology.h>
  73. #ifdef CONFIG_SMP
  74. #include <asm/cputable.h>
  75. #define smt_capable() (cpu_has_feature(CPU_FTR_SMT))
  76. #ifdef CONFIG_PPC64
  77. #include <asm/smp.h>
  78. #define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))
  79. #define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu))
  80. #define topology_thread_cpumask(cpu) (&per_cpu(cpu_sibling_map, cpu))
  81. #define topology_core_cpumask(cpu) (&per_cpu(cpu_core_map, cpu))
  82. #define topology_core_id(cpu) (cpu_to_core_id(cpu))
  83. #endif
  84. #endif
  85. #endif /* __KERNEL__ */
  86. #endif /* _ASM_POWERPC_TOPOLOGY_H */