topology.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * linux/include/asm-i386/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 _ASM_I386_TOPOLOGY_H
  28. #define _ASM_I386_TOPOLOGY_H
  29. #ifdef CONFIG_SMP
  30. #define topology_physical_package_id(cpu) \
  31. (phys_proc_id[cpu] == BAD_APICID ? -1 : phys_proc_id[cpu])
  32. #define topology_core_id(cpu) \
  33. (cpu_core_id[cpu] == BAD_APICID ? 0 : cpu_core_id[cpu])
  34. #define topology_core_siblings(cpu) (cpu_core_map[cpu])
  35. #define topology_thread_siblings(cpu) (cpu_sibling_map[cpu])
  36. #endif
  37. #ifdef CONFIG_NUMA
  38. #include <asm/mpspec.h>
  39. #include <linux/cpumask.h>
  40. /* Mappings between logical cpu number and node number */
  41. extern cpumask_t node_2_cpu_mask[];
  42. extern int cpu_2_node[];
  43. /* Returns the number of the node containing CPU 'cpu' */
  44. static inline int cpu_to_node(int cpu)
  45. {
  46. return cpu_2_node[cpu];
  47. }
  48. /* Returns the number of the node containing Node 'node'. This architecture is flat,
  49. so it is a pretty simple function! */
  50. #define parent_node(node) (node)
  51. /* Returns a bitmask of CPUs on Node 'node'. */
  52. static inline cpumask_t node_to_cpumask(int node)
  53. {
  54. return node_2_cpu_mask[node];
  55. }
  56. /* Returns the number of the first CPU on Node 'node'. */
  57. static inline int node_to_first_cpu(int node)
  58. {
  59. cpumask_t mask = node_to_cpumask(node);
  60. return first_cpu(mask);
  61. }
  62. #define pcibus_to_node(bus) ((long) (bus)->sysdata)
  63. #define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus))
  64. /* sched_domains SD_NODE_INIT for NUMAQ machines */
  65. #define SD_NODE_INIT (struct sched_domain) { \
  66. .span = CPU_MASK_NONE, \
  67. .parent = NULL, \
  68. .groups = NULL, \
  69. .min_interval = 8, \
  70. .max_interval = 32, \
  71. .busy_factor = 32, \
  72. .imbalance_pct = 125, \
  73. .cache_nice_tries = 1, \
  74. .busy_idx = 3, \
  75. .idle_idx = 1, \
  76. .newidle_idx = 2, \
  77. .wake_idx = 1, \
  78. .per_cpu_gain = 100, \
  79. .flags = SD_LOAD_BALANCE \
  80. | SD_BALANCE_EXEC \
  81. | SD_BALANCE_FORK \
  82. | SD_WAKE_BALANCE, \
  83. .last_balance = jiffies, \
  84. .balance_interval = 1, \
  85. .nr_balance_failed = 0, \
  86. }
  87. extern unsigned long node_start_pfn[];
  88. extern unsigned long node_end_pfn[];
  89. extern unsigned long node_remap_size[];
  90. #define node_has_online_mem(nid) (node_start_pfn[nid] != node_end_pfn[nid])
  91. #else /* !CONFIG_NUMA */
  92. /*
  93. * Other i386 platforms should define their own version of the
  94. * above macros here.
  95. */
  96. #include <asm-generic/topology.h>
  97. #endif /* CONFIG_NUMA */
  98. #endif /* _ASM_I386_TOPOLOGY_H */