aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid S. Miller2009-04-01 16:22:27 -0700
committerDavid S. Miller2009-06-16 04:56:25 -0700
commit0c243ad81f234672bebb72cf3dd014b9c841781d (patch)
tree2908de8577cc58b82fed8a4ac1e11536e27ad06e
parent73fffc037e2383a0ed126d57bdcda9b369769ae8 (diff)
sparc64: Only allocate per-cpu areas for possible cpus.
This gets us real close to the generic implementation of setup_per_cpu_areas() except: 1) We store the per-cpu offset into the trap_block[], whereas the generic code has it's own static array. 2) We have to initialize the %g5 register to hold the boot cpu's per-cpu area offset. 3) The OBP/MDESC cpu info scan is performed at the end. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--arch/sparc/kernel/smp_64.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 5302344e3cb4..567a6a47ba23 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -1373,27 +1373,17 @@ void smp_send_stop(void)
void __init setup_per_cpu_areas(void)
{
- unsigned long base, shift, goal, size, i;
+ unsigned long size, i, nr_possible_cpus = num_possible_cpus();
char *ptr;
/* Copy section for each CPU (we discard the original) */
- goal = PERCPU_ENOUGH_ROOM;
+ size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE);
+ ptr = alloc_bootmem_pages(size * nr_possible_cpus);
- shift = PAGE_SHIFT;
- for (size = PAGE_SIZE; size < goal; size <<= 1UL)
- shift++;
-
- ptr = __alloc_bootmem(size * NR_CPUS, PAGE_SIZE, 0);
- if (!ptr) {
- prom_printf("Cannot allocate per-cpu memory.\n");
- prom_halt();
- }
-
- base = ptr - __per_cpu_start;
-
- for (i = 0; i < NR_CPUS; i++, ptr += size) {
- __per_cpu_offset(i) = base + (i * size);
+ for_each_possible_cpu(i) {
+ __per_cpu_offset(i) = ptr - __per_cpu_start;
memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
+ ptr += size;
}
/* Setup %g5 for the boot cpu. */