topology.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 PENALTY_FOR_NODE_WITH_CPUS
  55. #define PENALTY_FOR_NODE_WITH_CPUS (1)
  56. #endif
  57. /*
  58. * Below are the 3 major initializers used in building sched_domains:
  59. * SD_SIBLING_INIT, for SMT domains
  60. * SD_CPU_INIT, for SMP domains
  61. * SD_NODE_INIT, for NUMA domains
  62. *
  63. * Any architecture that cares to do any tuning to these values should do so
  64. * by defining their own arch-specific initializer in include/asm/topology.h.
  65. * A definition there will automagically override these default initializers
  66. * and allow arch-specific performance tuning of sched_domains.
  67. */
  68. #ifdef CONFIG_SCHED_SMT
  69. /* MCD - Do we really need this? It is always on if CONFIG_SCHED_SMT is,
  70. * so can't we drop this in favor of CONFIG_SCHED_SMT?
  71. */
  72. #define ARCH_HAS_SCHED_WAKE_IDLE
  73. /* Common values for SMT siblings */
  74. #ifndef SD_SIBLING_INIT
  75. #define SD_SIBLING_INIT (struct sched_domain) { \
  76. .span = CPU_MASK_NONE, \
  77. .parent = NULL, \
  78. .groups = NULL, \
  79. .min_interval = 1, \
  80. .max_interval = 2, \
  81. .busy_factor = 8, \
  82. .imbalance_pct = 110, \
  83. .cache_hot_time = 0, \
  84. .cache_nice_tries = 0, \
  85. .per_cpu_gain = 25, \
  86. .busy_idx = 0, \
  87. .idle_idx = 0, \
  88. .newidle_idx = 1, \
  89. .wake_idx = 0, \
  90. .forkexec_idx = 0, \
  91. .flags = SD_LOAD_BALANCE \
  92. | SD_BALANCE_NEWIDLE \
  93. | SD_BALANCE_EXEC \
  94. | SD_WAKE_AFFINE \
  95. | SD_WAKE_IDLE \
  96. | SD_SHARE_CPUPOWER, \
  97. .last_balance = jiffies, \
  98. .balance_interval = 1, \
  99. .nr_balance_failed = 0, \
  100. }
  101. #endif
  102. #endif /* CONFIG_SCHED_SMT */
  103. /* Common values for CPUs */
  104. #ifndef SD_CPU_INIT
  105. #define SD_CPU_INIT (struct sched_domain) { \
  106. .span = CPU_MASK_NONE, \
  107. .parent = NULL, \
  108. .groups = NULL, \
  109. .min_interval = 1, \
  110. .max_interval = 4, \
  111. .busy_factor = 64, \
  112. .imbalance_pct = 125, \
  113. .cache_hot_time = (5*1000000/2), \
  114. .cache_nice_tries = 1, \
  115. .per_cpu_gain = 100, \
  116. .busy_idx = 2, \
  117. .idle_idx = 1, \
  118. .newidle_idx = 2, \
  119. .wake_idx = 1, \
  120. .forkexec_idx = 1, \
  121. .flags = SD_LOAD_BALANCE \
  122. | SD_BALANCE_NEWIDLE \
  123. | SD_BALANCE_EXEC \
  124. | SD_WAKE_AFFINE, \
  125. .last_balance = jiffies, \
  126. .balance_interval = 1, \
  127. .nr_balance_failed = 0, \
  128. }
  129. #endif
  130. #ifdef CONFIG_NUMA
  131. #ifndef SD_NODE_INIT
  132. #error Please define an appropriate SD_NODE_INIT in include/asm/topology.h!!!
  133. #endif
  134. #endif /* CONFIG_NUMA */
  135. #endif /* _LINUX_TOPOLOGY_H */