diff options
author | David S. Miller <davem@davemloft.net> | 2009-04-01 19:22:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-06-16 07:56:25 -0400 |
commit | 0c243ad81f234672bebb72cf3dd014b9c841781d (patch) | |
tree | 2908de8577cc58b82fed8a4ac1e11536e27ad06e /arch/sparc | |
parent | 73fffc037e2383a0ed126d57bdcda9b369769ae8 (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>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/kernel/smp_64.c | 22 |
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) | |||
1373 | 1373 | ||
1374 | void __init setup_per_cpu_areas(void) | 1374 | void __init setup_per_cpu_areas(void) |
1375 | { | 1375 | { |
1376 | unsigned long base, shift, goal, size, i; | 1376 | unsigned long size, i, nr_possible_cpus = num_possible_cpus(); |
1377 | char *ptr; | 1377 | char *ptr; |
1378 | 1378 | ||
1379 | /* Copy section for each CPU (we discard the original) */ | 1379 | /* Copy section for each CPU (we discard the original) */ |
1380 | goal = PERCPU_ENOUGH_ROOM; | 1380 | size = ALIGN(PERCPU_ENOUGH_ROOM, PAGE_SIZE); |
1381 | ptr = alloc_bootmem_pages(size * nr_possible_cpus); | ||
1381 | 1382 | ||
1382 | shift = PAGE_SHIFT; | 1383 | for_each_possible_cpu(i) { |
1383 | for (size = PAGE_SIZE; size < goal; size <<= 1UL) | 1384 | __per_cpu_offset(i) = ptr - __per_cpu_start; |
1384 | shift++; | ||
1385 | |||
1386 | ptr = __alloc_bootmem(size * NR_CPUS, PAGE_SIZE, 0); | ||
1387 | if (!ptr) { | ||
1388 | prom_printf("Cannot allocate per-cpu memory.\n"); | ||
1389 | prom_halt(); | ||
1390 | } | ||
1391 | |||
1392 | base = ptr - __per_cpu_start; | ||
1393 | |||
1394 | for (i = 0; i < NR_CPUS; i++, ptr += size) { | ||
1395 | __per_cpu_offset(i) = base + (i * size); | ||
1396 | memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); | 1385 | memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); |
1386 | ptr += size; | ||
1397 | } | 1387 | } |
1398 | 1388 | ||
1399 | /* Setup %g5 for the boot cpu. */ | 1389 | /* Setup %g5 for the boot cpu. */ |