topology.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. #ifndef node_distance
  49. /* Conform to ACPI 2.0 SLIT distance definitions */
  50. #define LOCAL_DISTANCE 10
  51. #define REMOTE_DISTANCE 20
  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. .groups = NULL, \
  87. .min_interval = 1, \
  88. .max_interval = 2, \
  89. .busy_factor = 8, \
  90. .imbalance_pct = 110, \
  91. .cache_nice_tries = 0, \
  92. .per_cpu_gain = 25, \
  93. .busy_idx = 0, \
  94. .idle_idx = 0, \
  95. .newidle_idx = 1, \
  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. /* Common values for CPUs */
  111. #ifndef SD_CPU_INIT
  112. #define SD_CPU_INIT (struct sched_domain) { \
  113. .span = CPU_MASK_NONE, \
  114. .parent = NULL, \
  115. .groups = NULL, \
  116. .min_interval = 1, \
  117. .max_interval = 4, \
  118. .busy_factor = 64, \
  119. .imbalance_pct = 125, \
  120. .cache_nice_tries = 1, \
  121. .per_cpu_gain = 100, \
  122. .busy_idx = 2, \
  123. .idle_idx = 1, \
  124. .newidle_idx = 2, \
  125. .wake_idx = 1, \
  126. .forkexec_idx = 1, \
  127. .flags = SD_LOAD_BALANCE \
  128. | SD_BALANCE_NEWIDLE \
  129. | SD_BALANCE_EXEC \
  130. | SD_WAKE_AFFINE, \
  131. .last_balance = jiffies, \
  132. .balance_interval = 1, \
  133. .nr_balance_failed = 0, \
  134. }
  135. #endif
  136. /* sched_domains SD_ALLNODES_INIT for NUMA machines */
  137. #define SD_ALLNODES_INIT (struct sched_domain) { \
  138. .span = CPU_MASK_NONE, \
  139. .parent = NULL, \
  140. .groups = NULL, \
  141. .min_interval = 64, \
  142. .max_interval = 64*num_online_cpus(), \
  143. .busy_factor = 128, \
  144. .imbalance_pct = 133, \
  145. .cache_hot_time = (10*1000000), \
  146. .cache_nice_tries = 1, \
  147. .busy_idx = 3, \
  148. .idle_idx = 3, \
  149. .newidle_idx = 0, /* unused */ \
  150. .wake_idx = 0, /* unused */ \
  151. .forkexec_idx = 0, /* unused */ \
  152. .per_cpu_gain = 100, \
  153. .flags = SD_LOAD_BALANCE, \
  154. .last_balance = jiffies, \
  155. .balance_interval = 64, \
  156. .nr_balance_failed = 0, \
  157. }
  158. #ifdef CONFIG_SCHED_MC
  159. #ifndef SD_MC_INIT
  160. /* for now its same as SD_CPU_INIT.
  161. * TBD: Tune Domain parameters!
  162. */
  163. #define SD_MC_INIT SD_CPU_INIT
  164. #endif
  165. #endif
  166. #ifdef CONFIG_NUMA
  167. #ifndef SD_NODE_INIT
  168. #error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!!
  169. #endif
  170. #endif /* CONFIG_NUMA */
  171. #endif /* _LINUX_TOPOLOGY_H */