diff options
author | Tejun Heo <tj@kernel.org> | 2011-01-23 08:37:30 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-01-28 08:54:05 -0500 |
commit | 4c321ff8a01a95badf5d5403d80ca4e0ab07fce7 (patch) | |
tree | 6fb9715b01c94988e20fa3ac2324c364854e6a79 /arch | |
parent | 1245e1668c6e52bee76a423f8fab3bfcdd6226ae (diff) |
x86: Replace cpu_2_logical_apicid[] with early percpu variable
Unlike x86_64, on x86_32, the mapping from cpu to logical apicid
may vary depending on apic in use. cpu_2_logical_apicid[] array
is used for this mapping. Replace it with early percpu variable
x86_cpu_to_logical_apicid to make it better aligned with other
mappings.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: eric.dumazet@gmail.com
Cc: yinghai@kernel.org
Cc: brgerst@gmail.com
Cc: gorcunov@gmail.com
Cc: penberg@kernel.org
Cc: shaohui.zheng@intel.com
Cc: rientjes@google.com
LKML-Reference: <1295789862-25482-5-git-send-email-tj@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/apic.h | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/smp.h | 3 | ||||
-rw-r--r-- | arch/x86/kernel/apic/apic.c | 11 | ||||
-rw-r--r-- | arch/x86/kernel/apic/es7000_32.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/apic/numaq_32.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/apic/summit_32.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/setup_percpu.c | 7 | ||||
-rw-r--r-- | arch/x86/kernel/smpboot.c | 7 |
8 files changed, 27 insertions, 13 deletions
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h index 5e3969c36d7f..eb139eced850 100644 --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h | |||
@@ -595,8 +595,4 @@ extern int default_check_phys_apicid_present(int phys_apicid); | |||
595 | 595 | ||
596 | #endif /* CONFIG_X86_LOCAL_APIC */ | 596 | #endif /* CONFIG_X86_LOCAL_APIC */ |
597 | 597 | ||
598 | #ifdef CONFIG_X86_32 | ||
599 | extern u8 cpu_2_logical_apicid[NR_CPUS]; | ||
600 | #endif | ||
601 | |||
602 | #endif /* _ASM_X86_APIC_H */ | 598 | #endif /* _ASM_X86_APIC_H */ |
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index 4c2f63c7fc1b..dc7c46a89db7 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h | |||
@@ -38,6 +38,9 @@ static inline struct cpumask *cpu_core_mask(int cpu) | |||
38 | 38 | ||
39 | DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); | 39 | DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); |
40 | DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); | 40 | DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); |
41 | #if defined(CONFIG_SMP) && defined(CONFIG_X86_32) | ||
42 | DECLARE_EARLY_PER_CPU(int, x86_cpu_to_logical_apicid); | ||
43 | #endif | ||
41 | 44 | ||
42 | /* Static state in head.S used to set up a CPU */ | 45 | /* Static state in head.S used to set up a CPU */ |
43 | extern struct { | 46 | extern struct { |
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c index 06c196d7e59c..126d5a3b00e9 100644 --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c | |||
@@ -78,6 +78,17 @@ EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_apicid); | |||
78 | EXPORT_EARLY_PER_CPU_SYMBOL(x86_bios_cpu_apicid); | 78 | EXPORT_EARLY_PER_CPU_SYMBOL(x86_bios_cpu_apicid); |
79 | 79 | ||
80 | #ifdef CONFIG_X86_32 | 80 | #ifdef CONFIG_X86_32 |
81 | |||
82 | #ifdef CONFIG_SMP | ||
83 | /* | ||
84 | * On x86_32, the mapping between cpu and logical apicid may vary | ||
85 | * depending on apic in use. The following early percpu variable is | ||
86 | * used for the mapping. This is where the behaviors of x86_64 and 32 | ||
87 | * actually diverge. Let's keep it ugly for now. | ||
88 | */ | ||
89 | DEFINE_EARLY_PER_CPU(int, x86_cpu_to_logical_apicid, BAD_APICID); | ||
90 | #endif | ||
91 | |||
81 | /* | 92 | /* |
82 | * Knob to control our willingness to enable the local APIC. | 93 | * Knob to control our willingness to enable the local APIC. |
83 | * | 94 | * |
diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c index 8593582d8022..7cb73e12f784 100644 --- a/arch/x86/kernel/apic/es7000_32.c +++ b/arch/x86/kernel/apic/es7000_32.c | |||
@@ -534,7 +534,7 @@ static int es7000_cpu_to_logical_apicid(int cpu) | |||
534 | #ifdef CONFIG_SMP | 534 | #ifdef CONFIG_SMP |
535 | if (cpu >= nr_cpu_ids) | 535 | if (cpu >= nr_cpu_ids) |
536 | return BAD_APICID; | 536 | return BAD_APICID; |
537 | return cpu_2_logical_apicid[cpu]; | 537 | return early_per_cpu(x86_cpu_to_logical_apicid, cpu); |
538 | #else | 538 | #else |
539 | return logical_smp_processor_id(); | 539 | return logical_smp_processor_id(); |
540 | #endif | 540 | #endif |
diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c index 960f26ab5c9f..4ed90c4882e9 100644 --- a/arch/x86/kernel/apic/numaq_32.c +++ b/arch/x86/kernel/apic/numaq_32.c | |||
@@ -377,7 +377,7 @@ static inline int numaq_cpu_to_logical_apicid(int cpu) | |||
377 | { | 377 | { |
378 | if (cpu >= nr_cpu_ids) | 378 | if (cpu >= nr_cpu_ids) |
379 | return BAD_APICID; | 379 | return BAD_APICID; |
380 | return cpu_2_logical_apicid[cpu]; | 380 | return early_per_cpu(x86_cpu_to_logical_apicid, cpu); |
381 | } | 381 | } |
382 | 382 | ||
383 | /* | 383 | /* |
diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c index 9b419263d90d..82cfc3ea70d1 100644 --- a/arch/x86/kernel/apic/summit_32.c +++ b/arch/x86/kernel/apic/summit_32.c | |||
@@ -206,7 +206,7 @@ static void summit_init_apic_ldr(void) | |||
206 | 206 | ||
207 | /* Create logical APIC IDs by counting CPUs already in cluster. */ | 207 | /* Create logical APIC IDs by counting CPUs already in cluster. */ |
208 | for (count = 0, i = nr_cpu_ids; --i >= 0; ) { | 208 | for (count = 0, i = nr_cpu_ids; --i >= 0; ) { |
209 | lid = cpu_2_logical_apicid[i]; | 209 | lid = early_per_cpu(x86_cpu_to_logical_apicid, i); |
210 | if (lid != BAD_APICID && APIC_CLUSTER(lid) == my_cluster) | 210 | if (lid != BAD_APICID && APIC_CLUSTER(lid) == my_cluster) |
211 | ++count; | 211 | ++count; |
212 | } | 212 | } |
@@ -247,7 +247,7 @@ static inline int summit_cpu_to_logical_apicid(int cpu) | |||
247 | #ifdef CONFIG_SMP | 247 | #ifdef CONFIG_SMP |
248 | if (cpu >= nr_cpu_ids) | 248 | if (cpu >= nr_cpu_ids) |
249 | return BAD_APICID; | 249 | return BAD_APICID; |
250 | return cpu_2_logical_apicid[cpu]; | 250 | return early_per_cpu(x86_cpu_to_logical_apicid, cpu); |
251 | #else | 251 | #else |
252 | return logical_smp_processor_id(); | 252 | return logical_smp_processor_id(); |
253 | #endif | 253 | #endif |
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c index 002b79685f73..b5147f00f0ef 100644 --- a/arch/x86/kernel/setup_percpu.c +++ b/arch/x86/kernel/setup_percpu.c | |||
@@ -225,6 +225,10 @@ void __init setup_per_cpu_areas(void) | |||
225 | per_cpu(x86_bios_cpu_apicid, cpu) = | 225 | per_cpu(x86_bios_cpu_apicid, cpu) = |
226 | early_per_cpu_map(x86_bios_cpu_apicid, cpu); | 226 | early_per_cpu_map(x86_bios_cpu_apicid, cpu); |
227 | #endif | 227 | #endif |
228 | #ifdef CONFIG_X86_32 | ||
229 | per_cpu(x86_cpu_to_logical_apicid, cpu) = | ||
230 | early_per_cpu_map(x86_cpu_to_logical_apicid, cpu); | ||
231 | #endif | ||
228 | #ifdef CONFIG_X86_64 | 232 | #ifdef CONFIG_X86_64 |
229 | per_cpu(irq_stack_ptr, cpu) = | 233 | per_cpu(irq_stack_ptr, cpu) = |
230 | per_cpu(irq_stack_union.irq_stack, cpu) + | 234 | per_cpu(irq_stack_union.irq_stack, cpu) + |
@@ -256,6 +260,9 @@ void __init setup_per_cpu_areas(void) | |||
256 | early_per_cpu_ptr(x86_cpu_to_apicid) = NULL; | 260 | early_per_cpu_ptr(x86_cpu_to_apicid) = NULL; |
257 | early_per_cpu_ptr(x86_bios_cpu_apicid) = NULL; | 261 | early_per_cpu_ptr(x86_bios_cpu_apicid) = NULL; |
258 | #endif | 262 | #endif |
263 | #ifdef CONFIG_X86_32 | ||
264 | early_per_cpu_ptr(x86_cpu_to_logical_apicid) = NULL; | ||
265 | #endif | ||
259 | #if defined(CONFIG_X86_64) && defined(CONFIG_NUMA) | 266 | #if defined(CONFIG_X86_64) && defined(CONFIG_NUMA) |
260 | early_per_cpu_ptr(x86_cpu_to_node_map) = NULL; | 267 | early_per_cpu_ptr(x86_cpu_to_node_map) = NULL; |
261 | #endif | 268 | #endif |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 53a85baaecca..df934e46bf53 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -165,9 +165,6 @@ static void unmap_cpu_to_node(int cpu) | |||
165 | #endif | 165 | #endif |
166 | 166 | ||
167 | #ifdef CONFIG_X86_32 | 167 | #ifdef CONFIG_X86_32 |
168 | u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly = | ||
169 | { [0 ... NR_CPUS-1] = BAD_APICID }; | ||
170 | |||
171 | static void map_cpu_to_logical_apicid(void) | 168 | static void map_cpu_to_logical_apicid(void) |
172 | { | 169 | { |
173 | int cpu = smp_processor_id(); | 170 | int cpu = smp_processor_id(); |
@@ -177,13 +174,13 @@ static void map_cpu_to_logical_apicid(void) | |||
177 | if (!node_online(node)) | 174 | if (!node_online(node)) |
178 | node = first_online_node; | 175 | node = first_online_node; |
179 | 176 | ||
180 | cpu_2_logical_apicid[cpu] = apicid; | 177 | early_per_cpu(x86_cpu_to_logical_apicid, cpu) = apicid; |
181 | map_cpu_to_node(cpu, node); | 178 | map_cpu_to_node(cpu, node); |
182 | } | 179 | } |
183 | 180 | ||
184 | void numa_remove_cpu(int cpu) | 181 | void numa_remove_cpu(int cpu) |
185 | { | 182 | { |
186 | cpu_2_logical_apicid[cpu] = BAD_APICID; | 183 | early_per_cpu(x86_cpu_to_logical_apicid, cpu) = BAD_APICID; |
187 | unmap_cpu_to_node(cpu); | 184 | unmap_cpu_to_node(cpu); |
188 | } | 185 | } |
189 | #else | 186 | #else |