diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2010-01-28 08:23:22 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-03-08 19:52:52 -0500 |
commit | 1426d5a3bd07589534286375998c0c8c6fdc5260 (patch) | |
tree | fade4f3afd6324b46e27f3c8702935a7edc2fe21 /arch/powerpc/kernel/setup_64.c | |
parent | 59603b9ae426e968d452f9325cdcff308573dee7 (diff) |
powerpc: Dynamically allocate pacas
On 64-bit kernels we currently have a 512 byte struct paca_struct for
each cpu (usually just called "the paca"). Currently they are statically
allocated, which means a kernel built for a large number of cpus will
waste a lot of space if it's booted on a machine with few cpus.
We can avoid that by only allocating the number of pacas we need at
boot. However this is complicated by the fact that we need to access
the paca before we know how many cpus there are in the system.
The solution is to dynamically allocate enough space for NR_CPUS pacas,
but then later in boot when we know how many cpus we have, we free any
unused pacas.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/setup_64.c')
-rw-r--r-- | arch/powerpc/kernel/setup_64.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index 6568406b2a30..63547394048c 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c | |||
@@ -144,9 +144,9 @@ early_param("smt-enabled", early_smt_enabled); | |||
144 | #endif /* CONFIG_SMP */ | 144 | #endif /* CONFIG_SMP */ |
145 | 145 | ||
146 | /* Put the paca pointer into r13 and SPRG_PACA */ | 146 | /* Put the paca pointer into r13 and SPRG_PACA */ |
147 | void __init setup_paca(int cpu) | 147 | static void __init setup_paca(struct paca_struct *new_paca) |
148 | { | 148 | { |
149 | local_paca = &paca[cpu]; | 149 | local_paca = new_paca; |
150 | mtspr(SPRN_SPRG_PACA, local_paca); | 150 | mtspr(SPRN_SPRG_PACA, local_paca); |
151 | #ifdef CONFIG_PPC_BOOK3E | 151 | #ifdef CONFIG_PPC_BOOK3E |
152 | mtspr(SPRN_SPRG_TLB_EXFRAME, local_paca->extlb); | 152 | mtspr(SPRN_SPRG_TLB_EXFRAME, local_paca->extlb); |
@@ -176,14 +176,12 @@ void __init early_setup(unsigned long dt_ptr) | |||
176 | { | 176 | { |
177 | /* -------- printk is _NOT_ safe to use here ! ------- */ | 177 | /* -------- printk is _NOT_ safe to use here ! ------- */ |
178 | 178 | ||
179 | /* Fill in any unititialised pacas */ | ||
180 | initialise_pacas(); | ||
181 | |||
182 | /* Identify CPU type */ | 179 | /* Identify CPU type */ |
183 | identify_cpu(0, mfspr(SPRN_PVR)); | 180 | identify_cpu(0, mfspr(SPRN_PVR)); |
184 | 181 | ||
185 | /* Assume we're on cpu 0 for now. Don't write to the paca yet! */ | 182 | /* Assume we're on cpu 0 for now. Don't write to the paca yet! */ |
186 | setup_paca(0); | 183 | initialise_paca(&boot_paca, 0); |
184 | setup_paca(&boot_paca); | ||
187 | 185 | ||
188 | /* Initialize lockdep early or else spinlocks will blow */ | 186 | /* Initialize lockdep early or else spinlocks will blow */ |
189 | lockdep_init(); | 187 | lockdep_init(); |
@@ -203,7 +201,7 @@ void __init early_setup(unsigned long dt_ptr) | |||
203 | early_init_devtree(__va(dt_ptr)); | 201 | early_init_devtree(__va(dt_ptr)); |
204 | 202 | ||
205 | /* Now we know the logical id of our boot cpu, setup the paca. */ | 203 | /* Now we know the logical id of our boot cpu, setup the paca. */ |
206 | setup_paca(boot_cpuid); | 204 | setup_paca(&paca[boot_cpuid]); |
207 | 205 | ||
208 | /* Fix up paca fields required for the boot cpu */ | 206 | /* Fix up paca fields required for the boot cpu */ |
209 | get_paca()->cpu_start = 1; | 207 | get_paca()->cpu_start = 1; |