aboutsummaryrefslogtreecommitdiffstats
path: root/init/main.c
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2006-03-23 06:01:04 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-23 10:38:17 -0500
commit63872f87a151413100678f110d1556026002809e (patch)
tree4abb8b8c7f60a9d2c6645c4eb9e95a9c6ba56023 /init/main.c
parent5a6b7951bfcca7f45f44269ea87417c74558daf8 (diff)
[PATCH] Only allocate percpu data for possible CPUs
percpu_data blindly allocates bootmem memory to store NR_CPUS instances of cpudata, instead of allocating memory only for possible cpus. This patch saves ram, allocating num_possible_cpus() (instead of NR_CPUS) instances. Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Acked-by: "David S. Miller" <davem@davemloft.net> Cc: James Bottomley <James.Bottomley@steeleye.com> Cc: Jens Axboe <axboe@suse.de> Acked-by: Ingo Molnar <mingo@elte.hu> Cc: Jens Axboe <axboe@suse.de> Cc: Anton Blanchard <anton@samba.org> Acked-by: William Irwin <wli@holomorphy.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'init/main.c')
-rw-r--r--init/main.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/init/main.c b/init/main.c
index 141e8896d252..9cf6b307bfd7 100644
--- a/init/main.c
+++ b/init/main.c
@@ -333,6 +333,7 @@ static void __init setup_per_cpu_areas(void)
333{ 333{
334 unsigned long size, i; 334 unsigned long size, i;
335 char *ptr; 335 char *ptr;
336 unsigned long nr_possible_cpus = num_possible_cpus();
336 337
337 /* Copy section for each CPU (we discard the original) */ 338 /* Copy section for each CPU (we discard the original) */
338 size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES); 339 size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
@@ -340,12 +341,16 @@ static void __init setup_per_cpu_areas(void)
340 if (size < PERCPU_ENOUGH_ROOM) 341 if (size < PERCPU_ENOUGH_ROOM)
341 size = PERCPU_ENOUGH_ROOM; 342 size = PERCPU_ENOUGH_ROOM;
342#endif 343#endif
344 ptr = alloc_bootmem(size * nr_possible_cpus);
343 345
344 ptr = alloc_bootmem(size * NR_CPUS); 346 for (i = 0; i < NR_CPUS; i++) {
345 347 if (!cpu_possible(i)) {
346 for (i = 0; i < NR_CPUS; i++, ptr += size) { 348 __per_cpu_offset[i] = (char*)0 - __per_cpu_start;
349 continue;
350 }
347 __per_cpu_offset[i] = ptr - __per_cpu_start; 351 __per_cpu_offset[i] = ptr - __per_cpu_start;
348 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); 352 memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
353 ptr += size;
349 } 354 }
350} 355}
351#endif /* !__GENERIC_PER_CPU */ 356#endif /* !__GENERIC_PER_CPU */