Blame view

arch/x86/include/asm/topology.h 4.91 KB
3367e56f2   Thomas Gleixner   x86: merge topolo...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  /*
   * Written by: Matthew Dobson, IBM Corporation
   *
   * Copyright (C) 2002, IBM Corp.
   *
   * All rights reserved.
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
   * NON INFRINGEMENT.  See the GNU General Public License for more
   * details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   *
   * Send feedback to <colpatch@us.ibm.com>
   */
1965aae3c   H. Peter Anvin   x86: Fix ASM_X86_...
25
26
  #ifndef _ASM_X86_TOPOLOGY_H
  #define _ASM_X86_TOPOLOGY_H
3367e56f2   Thomas Gleixner   x86: merge topolo...
27

5c3a121d5   Vaidyanathan Srinivasan   x86: sysfs cpu?/t...
28
29
30
31
32
33
34
35
36
  #ifdef CONFIG_X86_32
  # ifdef CONFIG_X86_HT
  #  define ENABLE_TOPO_DEFINES
  # endif
  #else
  # ifdef CONFIG_SMP
  #  define ENABLE_TOPO_DEFINES
  # endif
  #endif
4e25b2576   Lee Schermerhorn   hugetlb: add gene...
37
38
39
40
41
42
  /*
   * to preserve the visibility of NUMA_NO_NODE definition,
   * moved to there from here.  May be used independent of
   * CONFIG_NUMA.
   */
  #include <linux/numa.h>
23ca4bba3   Mike Travis   x86: cleanup earl...
43

3367e56f2   Thomas Gleixner   x86: merge topolo...
44
45
  #ifdef CONFIG_NUMA
  #include <linux/cpumask.h>
4e25b2576   Lee Schermerhorn   hugetlb: add gene...
46

3367e56f2   Thomas Gleixner   x86: merge topolo...
47
  #include <asm/mpspec.h>
23ca4bba3   Mike Travis   x86: cleanup earl...
48
49
  /* Mappings between logical cpu number and node number */
  DECLARE_EARLY_PER_CPU(int, x86_cpu_to_node_map);
23ca4bba3   Mike Travis   x86: cleanup earl...
50
  #ifdef CONFIG_DEBUG_PER_CPU_MAPS
e534c7c5f   Lee Schermerhorn   numa: x86_64: use...
51
52
53
54
55
  /*
   * override generic percpu implementation of cpu_to_node
   */
  extern int __cpu_to_node(int cpu);
  #define cpu_to_node __cpu_to_node
23ca4bba3   Mike Travis   x86: cleanup earl...
56
  extern int early_cpu_to_node(int cpu);
3367e56f2   Thomas Gleixner   x86: merge topolo...
57

23ca4bba3   Mike Travis   x86: cleanup earl...
58
  #else	/* !CONFIG_DEBUG_PER_CPU_MAPS */
23ca4bba3   Mike Travis   x86: cleanup earl...
59
60
61
  /* Same function but used if called before per_cpu areas are setup */
  static inline int early_cpu_to_node(int cpu)
  {
f10fcd471   Tejun Heo   x86: make early_p...
62
  	return early_per_cpu(x86_cpu_to_node_map, cpu);
23ca4bba3   Mike Travis   x86: cleanup earl...
63
  }
834beda15   travis@sgi.com   x86: change NR_CP...
64

71ee73e72   Rusty Russell   x86: unify 32 and...
65
  #endif /* !CONFIG_DEBUG_PER_CPU_MAPS */
71ee73e72   Rusty Russell   x86: unify 32 and...
66
  /* Mappings between node number and cpus on that node. */
c032ef60d   Rusty Russell   cpumask: convert ...
67
  extern cpumask_var_t node_to_cpumask_map[MAX_NUMNODES];
71ee73e72   Rusty Russell   x86: unify 32 and...
68
69
  
  #ifdef CONFIG_DEBUG_PER_CPU_MAPS
73e907de7   Rusty Russell   cpumask: remove x...
70
  extern const struct cpumask *cpumask_of_node(int node);
71ee73e72   Rusty Russell   x86: unify 32 and...
71
  #else
23ca4bba3   Mike Travis   x86: cleanup earl...
72
  /* Returns a pointer to the cpumask of CPUs on Node 'node'. */
c032ef60d   Rusty Russell   cpumask: convert ...
73
  static inline const struct cpumask *cpumask_of_node(int node)
3367e56f2   Thomas Gleixner   x86: merge topolo...
74
75
76
  {
  	return node_to_cpumask_map[node];
  }
71ee73e72   Rusty Russell   x86: unify 32 and...
77
  #endif
23ca4bba3   Mike Travis   x86: cleanup earl...
78

6470aff61   Brian Gerst   x86: move 64-bit ...
79
  extern void setup_node_to_cpumask_map(void);
393d68fb9   Rusty Russell   cpumask: x86: Int...
80
  /*
23ca4bba3   Mike Travis   x86: cleanup earl...
81
82
83
84
   * Returns the number of the node containing Node 'node'. This
   * architecture is flat, so it is a pretty simple function!
   */
  #define parent_node(node) (node)
3367e56f2   Thomas Gleixner   x86: merge topolo...
85
  #define pcibus_to_node(bus) __pcibus_to_node(bus)
3367e56f2   Thomas Gleixner   x86: merge topolo...
86

96a388de5   Thomas Gleixner   i386/x86_64: move...
87
  #ifdef CONFIG_X86_32
3367e56f2   Thomas Gleixner   x86: merge topolo...
88
89
  # define SD_CACHE_NICE_TRIES	1
  # define SD_IDLE_IDX		1
96a388de5   Thomas Gleixner   i386/x86_64: move...
90
  #else
3367e56f2   Thomas Gleixner   x86: merge topolo...
91
92
  # define SD_CACHE_NICE_TRIES	2
  # define SD_IDLE_IDX		2
3367e56f2   Thomas Gleixner   x86: merge topolo...
93
  #endif
9fcd18c9e   Ingo Molnar   sched: re-tune ba...
94
  /* sched_domains SD_NODE_INIT for NUMA machines */
47734f89b   Ingo Molnar   sched: Clean up t...
95
96
97
98
99
100
101
102
  #define SD_NODE_INIT (struct sched_domain) {				\
  	.min_interval		= 8,					\
  	.max_interval		= 32,					\
  	.busy_factor		= 32,					\
  	.imbalance_pct		= 125,					\
  	.cache_nice_tries	= SD_CACHE_NICE_TRIES,			\
  	.busy_idx		= 3,					\
  	.idle_idx		= SD_IDLE_IDX,				\
0ec9fab3d   Mike Galbraith   sched: Improve la...
103
  	.newidle_idx		= 0,					\
78e7ed53c   Peter Zijlstra   sched: Tweak wake...
104
  	.wake_idx		= 0,					\
b8a543ea5   Peter Zijlstra   sched: Reduce for...
105
  	.forkexec_idx		= 0,					\
47734f89b   Ingo Molnar   sched: Clean up t...
106
107
  									\
  	.flags			= 1*SD_LOAD_BALANCE			\
840a06531   Ingo Molnar   sched: Turn on SD...
108
  				| 1*SD_BALANCE_NEWIDLE			\
47734f89b   Ingo Molnar   sched: Clean up t...
109
110
  				| 1*SD_BALANCE_EXEC			\
  				| 1*SD_BALANCE_FORK			\
182a85f8a   Peter Zijlstra   sched: Disable wa...
111
  				| 0*SD_BALANCE_WAKE			\
47734f89b   Ingo Molnar   sched: Clean up t...
112
  				| 1*SD_WAKE_AFFINE			\
6b9de613a   Mike Galbraith   sched: Disable SD...
113
  				| 0*SD_PREFER_LOCAL			\
47734f89b   Ingo Molnar   sched: Clean up t...
114
115
116
117
  				| 0*SD_SHARE_CPUPOWER			\
  				| 0*SD_POWERSAVINGS_BALANCE		\
  				| 0*SD_SHARE_PKG_RESOURCES		\
  				| 1*SD_SERIALIZE			\
47734f89b   Ingo Molnar   sched: Clean up t...
118
119
120
121
  				| 0*SD_PREFER_SIBLING			\
  				,					\
  	.last_balance		= jiffies,				\
  	.balance_interval	= 1,					\
3367e56f2   Thomas Gleixner   x86: merge topolo...
122
  }
3367e56f2   Thomas Gleixner   x86: merge topolo...
123
124
  extern int __node_distance(int, int);
  #define node_distance(a, b) __node_distance(a, b)
3367e56f2   Thomas Gleixner   x86: merge topolo...
125

23ca4bba3   Mike Travis   x86: cleanup earl...
126
  #else /* !CONFIG_NUMA */
f2a082711   Mike Travis   x86: fix build wa...
127
128
129
130
  static inline int numa_node_id(void)
  {
  	return 0;
  }
728120192   Lee Schermerhorn   numa: add generic...
131
132
133
134
  /*
   * indicate override:
   */
  #define numa_node_id numa_node_id
f2a082711   Mike Travis   x86: fix build wa...
135

f2a082711   Mike Travis   x86: fix build wa...
136
137
138
139
  static inline int early_cpu_to_node(int cpu)
  {
  	return 0;
  }
23ca4bba3   Mike Travis   x86: cleanup earl...
140

6470aff61   Brian Gerst   x86: move 64-bit ...
141
  static inline void setup_node_to_cpumask_map(void) { }
3367e56f2   Thomas Gleixner   x86: merge topolo...
142
  #endif
aa6b54461   Mike Travis   asm-generic: add ...
143
  #include <asm-generic/topology.h>
030bb203e   Rusty Russell   cpumask: cpu_core...
144
  extern const struct cpumask *cpu_coregroup_mask(int cpu);
3367e56f2   Thomas Gleixner   x86: merge topolo...
145
146
147
148
  
  #ifdef ENABLE_TOPO_DEFINES
  #define topology_physical_package_id(cpu)	(cpu_data(cpu).phys_proc_id)
  #define topology_core_id(cpu)			(cpu_data(cpu).cpu_core_id)
7ad728f98   Rusty Russell   cpumask: x86: con...
149
150
  #define topology_core_cpumask(cpu)		(per_cpu(cpu_core_map, cpu))
  #define topology_thread_cpumask(cpu)		(per_cpu(cpu_sibling_map, cpu))
23ca4bba3   Mike Travis   x86: cleanup earl...
151
152
153
  
  /* indicates that pointers to the topology cpumask_t maps are valid */
  #define arch_provides_topology_pointers		yes
3367e56f2   Thomas Gleixner   x86: merge topolo...
154
  #endif
fe086a7be   Alex Chiang   [IA64] Provide AC...
155
156
157
  static inline void arch_fix_phys_package_id(int num, u32 slot)
  {
  }
30a18d6c3   Yinghai Lu   x86: multi pci ro...
158
  struct pci_bus;
2cd6975a4   Bjorn Helgaas   x86/PCI: convert ...
159
  void x86_pci_root_bus_resources(int bus, struct list_head *resources);
30a18d6c3   Yinghai Lu   x86: multi pci ro...
160

3367e56f2   Thomas Gleixner   x86: merge topolo...
161
  #ifdef CONFIG_SMP
2ff799d3c   Vaidyanathan Srinivasan   sched: Don't expo...
162
163
  #define mc_capable()	((boot_cpu_data.x86_max_cores > 1) && \
  			(cpumask_weight(cpu_core_mask(0)) != nr_cpu_ids))
3367e56f2   Thomas Gleixner   x86: merge topolo...
164
165
  #define smt_capable()			(smp_num_siblings > 1)
  #endif
871d5f8dd   Yinghai Lu   x86: get mp_bus_t...
166
167
168
169
170
171
172
173
174
175
176
177
  #ifdef CONFIG_NUMA
  extern int get_mp_bus_to_node(int busnum);
  extern void set_mp_bus_to_node(int busnum, int node);
  #else
  static inline int get_mp_bus_to_node(int busnum)
  {
  	return 0;
  }
  static inline void set_mp_bus_to_node(int busnum, int node)
  {
  }
  #endif
1965aae3c   H. Peter Anvin   x86: Fix ASM_X86_...
178
  #endif /* _ASM_X86_TOPOLOGY_H */