topology.h 2.3 KB

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