Skip to content

Commit

Permalink
[PATCH] Only allocate percpu data for possible CPUs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and Linus Torvalds committed Mar 23, 2006
1 parent 5a6b795 commit 63872f8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,19 +333,24 @@ static void __init setup_per_cpu_areas(void)
{
unsigned long size, i;
char *ptr;
unsigned long nr_possible_cpus = num_possible_cpus();

/* Copy section for each CPU (we discard the original) */
size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
#ifdef CONFIG_MODULES
if (size < PERCPU_ENOUGH_ROOM)
size = PERCPU_ENOUGH_ROOM;
#endif
ptr = alloc_bootmem(size * nr_possible_cpus);

ptr = alloc_bootmem(size * NR_CPUS);

for (i = 0; i < NR_CPUS; i++, ptr += size) {
for (i = 0; i < NR_CPUS; i++) {
if (!cpu_possible(i)) {
__per_cpu_offset[i] = (char*)0 - __per_cpu_start;
continue;
}
__per_cpu_offset[i] = ptr - __per_cpu_start;
memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
ptr += size;
}
}
#endif /* !__GENERIC_PER_CPU */
Expand Down

0 comments on commit 63872f8

Please sign in to comment.