diff options
author | Tejun Heo <tj@kernel.org> | 2009-01-13 06:41:35 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-01-16 08:20:03 -0500 |
commit | b12d8db8fbfaed1e8222a15333a3645599636854 (patch) | |
tree | 4ae6ce55232885d0707eb464c5b43a54bdfe3ce4 /arch/x86/kernel/setup_percpu.c | |
parent | 9939ddaff52787b2a7c1adf1b2afc95421aa0884 (diff) |
x86: make pda a percpu variable
[ Based on original patch from Christoph Lameter and Mike Travis. ]
As pda is now allocated in percpu area, it can easily be made a proper
percpu variable. Make it so by defining per cpu symbol from linker
script and declaring it in C code for SMP and simply defining it for
UP. This change cleans up code and brings SMP and UP closer a bit.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/setup_percpu.c')
-rw-r--r-- | arch/x86/kernel/setup_percpu.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c index be1ff34db112..daeedf82c15f 100644 --- a/arch/x86/kernel/setup_percpu.c +++ b/arch/x86/kernel/setup_percpu.c | |||
@@ -66,6 +66,16 @@ static void __init setup_node_to_cpumask_map(void); | |||
66 | static inline void setup_node_to_cpumask_map(void) { } | 66 | static inline void setup_node_to_cpumask_map(void) { } |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | /* | ||
70 | * Define load_pda_offset() and per-cpu __pda for x86_64. | ||
71 | * load_pda_offset() is responsible for loading the offset of pda into | ||
72 | * %gs. | ||
73 | * | ||
74 | * On SMP, pda offset also duals as percpu base address and thus it | ||
75 | * should be at the start of per-cpu area. To achieve this, it's | ||
76 | * preallocated in vmlinux_64.lds.S directly instead of using | ||
77 | * DEFINE_PER_CPU(). | ||
78 | */ | ||
69 | #ifdef CONFIG_X86_64 | 79 | #ifdef CONFIG_X86_64 |
70 | void __cpuinit load_pda_offset(int cpu) | 80 | void __cpuinit load_pda_offset(int cpu) |
71 | { | 81 | { |
@@ -74,6 +84,10 @@ void __cpuinit load_pda_offset(int cpu) | |||
74 | wrmsrl(MSR_GS_BASE, cpu_pda(cpu)); | 84 | wrmsrl(MSR_GS_BASE, cpu_pda(cpu)); |
75 | mb(); | 85 | mb(); |
76 | } | 86 | } |
87 | #ifndef CONFIG_SMP | ||
88 | DEFINE_PER_CPU(struct x8664_pda, __pda); | ||
89 | EXPORT_PER_CPU_SYMBOL(__pda); | ||
90 | #endif | ||
77 | 91 | ||
78 | #endif /* CONFIG_SMP && CONFIG_X86_64 */ | 92 | #endif /* CONFIG_SMP && CONFIG_X86_64 */ |
79 | 93 | ||
@@ -180,8 +194,6 @@ void __init setup_per_cpu_areas(void) | |||
180 | memcpy(ptr, __per_cpu_load, __per_cpu_end - __per_cpu_start); | 194 | memcpy(ptr, __per_cpu_load, __per_cpu_end - __per_cpu_start); |
181 | per_cpu_offset(cpu) = ptr - __per_cpu_start; | 195 | per_cpu_offset(cpu) = ptr - __per_cpu_start; |
182 | #ifdef CONFIG_X86_64 | 196 | #ifdef CONFIG_X86_64 |
183 | cpu_pda(cpu) = (void *)ptr; | ||
184 | |||
185 | /* | 197 | /* |
186 | * CPU0 modified pda in the init data area, reload pda | 198 | * CPU0 modified pda in the init data area, reload pda |
187 | * offset for CPU0 and clear the area for others. | 199 | * offset for CPU0 and clear the area for others. |