topology.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * include/linux/topology.h
  3. *
  4. * Written by: Matthew Dobson, IBM Corporation
  5. *
  6. * Copyright (C) 2002, IBM Corp.
  7. *
  8. * All rights reserved.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  18. * NON INFRINGEMENT. See the GNU General Public License for more
  19. * details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. *
  25. * Send feedback to <colpatch@us.ibm.com>
  26. */
  27. #ifndef _LINUX_TOPOLOGY_H
  28. #define _LINUX_TOPOLOGY_H
  29. #include <linux/cpumask.h>
  30. #include <linux/bitops.h>
  31. #include <linux/mmzone.h>
  32. #include <linux/smp.h>
  33. #include <asm/topology.h>
  34. #ifndef node_has_online_mem
  35. #define node_has_online_mem(nid) (1)
  36. #endif
  37. #ifndef nr_cpus_node
  38. #define nr_cpus_node(node) \
  39. ({ \
  40. cpumask_t __tmp__; \
  41. __tmp__ = node_to_cpumask(node); \
  42. cpus_weight(__tmp__); \
  43. })
  44. #endif
  45. #define for_each_node_with_cpus(node) \
  46. for_each_online_node(node) \
  47. if (nr_cpus_node(node))
  48. /* Conform to ACPI 2.0 SLIT distance definitions */
  49. #define LOCAL_DISTANCE 10
  50. #define REMOTE_DISTANCE 20
  51. #ifndef node_distance
  52. #define node_distance(from,to) ((from) == (to) ? LOCAL_DISTANCE : REMOTE_DISTANCE)
  53. #endif
  54. #ifndef RECLAIM_DISTANCE
  55. /*
  56. * If the distance between nodes in a system is larger than RECLAIM_DISTANCE
  57. * (in whatever arch specific measurement units returned by node_distance())
  58. * then switch on zone reclaim on boot.
  59. */
  60. #define RECLAIM_DISTANCE 20
  61. #endif
  62. #ifndef PENALTY_FOR_NODE_WITH_CPUS
  63. #define PENALTY_FOR_NODE_WITH_CPUS (1)
  64. #endif
  65. /*
  66. * Below are the 3 major initializers used in building sched_domains:
  67. * SD_SIBLING_INIT, for SMT domains
  68. * SD_CPU_INIT, for SMP domains
  69. * SD_NODE_INIT, for NUMA domains
  70. *
  71. * Any architecture that cares to do any tuning to these values should do so
  72. * by defining their own arch-specific initializer in include/asm/topology.h.
  73. * A definition there will automagically override these default initializers
  74. * and allow arch-specific performance tuning of sched_domains.
  75. */
  76. #ifdef CONFIG_SCHED_SMT
  77. /* MCD - Do we really need this? It is always on if CONFIG_SCHED_SMT is,
  78. * so can't we drop this in favor of CONFIG_SCHED_SMT?
  79. */
  80. #define ARCH_HAS_SCHED_WAKE_IDLE
  81. /* Common values for SMT siblings */
  82. #ifndef SD_SIBLING_INIT
  83. #define SD_SIBLING_INIT (struct sched_domain) { \
  84. .span = CPU_MASK_NONE, \
  85. .parent = NULL, \
  86. .child = NULL, \
  87. .groups = NULL, \
  88. .min_interval = 1, \
  89. .max_interval = 2, \
  90. .busy_factor = 64, \
  91. .imbalance_pct = 110, \
  92. .cache_nice_tries = 0, \
  93. .busy_idx = 0, \
  94. .idle_idx = 0, \
  95. .newidle_idx = 0, \
  96. .wake_idx = 0, \
  97. .forkexec_idx = 0, \
  98. .flags = SD_LOAD_BALANCE \
  99. | SD_BALANCE_NEWIDLE \
  100. | SD_BALANCE_EXEC \
  101. | SD_WAKE_AFFINE \
  102. | SD_WAKE_IDLE \
  103. | SD_SHARE_CPUPOWER, \
  104. .last_balance = jiffies, \
  105. .balance_interval = 1, \
  106. .nr_balance_failed = 0, \
  107. }
  108. #endif
  109. #endif /* CONFIG_SCHED_SMT */
  110. #ifdef CONFIG_SCHED_MC
  111. /* Common values for MC siblings. for now mostly derived from SD_CPU_INIT */
  112. #ifndef SD_MC_INIT
  113. #define SD_MC_INIT (struct sched_domain) { \
  114. .span = CPU_MASK_NONE, \
  115. .parent = NULL, \
  116. .child = NULL, \
  117. .groups = NULL, \
  118. .min_interval = 1, \
  119. .max_interval = 4, \
  120. .busy_factor = 64, \
  121. .imbalance_pct = 125, \
  122. .cache_nice_tries = 1, \
  123. .busy_idx = 2, \
  124. .idle_idx = 0, \
  125. .newidle_idx = 0, \
  126. .wake_idx = 1, \
  127. .forkexec_idx = 1, \
  128. .flags = SD_LOAD_BALANCE \
  129. | SD_BALANCE_NEWIDLE \
  130. | SD_BALANCE_EXEC \
  131. | SD_WAKE_AFFINE \
  132. | SD_WAKE_IDLE \
  133. | SD_SHARE_PKG_RESOURCES\
  134. | BALANCE_FOR_MC_POWER, \
  135. .last_balance = jiffies, \
  136. .balance_interval = 1, \
  137. .nr_balance_failed = 0, \
  138. }
  139. #endif
  140. #endif /* CONFIG_SCHED_MC */
  141. /* Common values for CPUs */
  142. #ifndef SD_CPU_INIT
  143. #define SD_CPU_INIT (struct sched_domain) { \
  144. .span = CPU_MASK_NONE, \
  145. .parent = NULL, \
  146. .child = NULL, \
  147. .groups = NULL, \
  148. .min_interval = 1, \
  149. .max_interval = 4, \
  150. .busy_factor = 64, \
  151. .imbalance_pct = 125, \
  152. .cache_nice_tries = 1, \
  153. .busy_idx = 2, \
  154. .idle_idx = 0, \
  155. .newidle_idx = 0, \
  156. .wake_idx = 1, \
  157. .forkexec_idx = 1, \
  158. .flags = SD_LOAD_BALANCE \
  159. | SD_BALANCE_NEWIDLE \
  160. | SD_BALANCE_EXEC \
  161. | SD_WAKE_AFFINE \
  162. | SD_WAKE_IDLE \
  163. | BALANCE_FOR_PKG_POWER,\
  164. .last_balance = jiffies, \
  165. .balance_interval = 1, \
  166. .nr_balance_failed = 0, \
  167. }
  168. #endif
  169. /* sched_domains SD_ALLNODES_INIT for NUMA machines */
  170. #define SD_ALLNODES_INIT (struct sched_domain) { \
  171. .span = CPU_MASK_NONE, \
  172. .parent = NULL, \
  173. .child = NULL, \
  174. .groups = NULL, \
  175. .min_interval = 64, \
  176. .max_interval = 64*num_online_cpus(), \
  177. .busy_factor = 128, \
  178. .imbalance_pct = 133, \
  179. .cache_hot_time = (10*1000000), \
  180. .cache_nice_tries = 1, \
  181. .busy_idx = 3, \
  182. .idle_idx = 3, \
  183. .newidle_idx = 0, /* unused */ \
  184. .wake_idx = 0, /* unused */ \
  185. .forkexec_idx = 0, /* unused */ \
  186. .flags = SD_LOAD_BALANCE \
  187. | SD_SERIALIZE, \
  188. .last_balance = jiffies, \
  189. .balance_interval = 64, \
  190. .nr_balance_failed = 0, \
  191. }
  192. #ifdef CONFIG_NUMA
  193. #ifndef SD_NODE_INIT
  194. #error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!!
  195. #endif
  196. #endif /* CONFIG_NUMA */
  197. #endif /* _LINUX_TOPOLOGY_H */