Commit 63872f87 authored by Eric Dumazet's avatar Eric Dumazet Committed by Linus Torvalds
Browse files

[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: default avatarEric Dumazet <dada1@cosmosbay.com>
Acked-by: default avatar"David S. Miller" <davem@davemloft.net>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: Jens Axboe <axboe@suse.de>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Cc: Jens Axboe <axboe@suse.de>
Cc: Anton Blanchard <anton@samba.org>
Acked-by: default avatarWilliam Irwin <wli@holomorphy.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5a6b7951
...@@ -333,6 +333,7 @@ static void __init setup_per_cpu_areas(void) ...@@ -333,6 +333,7 @@ static void __init setup_per_cpu_areas(void)
{ {
unsigned long size, i; unsigned long size, i;
char *ptr; char *ptr;
unsigned long nr_possible_cpus = num_possible_cpus();
/* Copy section for each CPU (we discard the original) */ /* Copy section for each CPU (we discard the original) */
size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES); size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
...@@ -340,12 +341,16 @@ static void __init setup_per_cpu_areas(void) ...@@ -340,12 +341,16 @@ static void __init setup_per_cpu_areas(void)
if (size < PERCPU_ENOUGH_ROOM) if (size < PERCPU_ENOUGH_ROOM)
size = PERCPU_ENOUGH_ROOM; size = PERCPU_ENOUGH_ROOM;
#endif #endif
ptr = alloc_bootmem(size * nr_possible_cpus);
ptr = alloc_bootmem(size * NR_CPUS); for (i = 0; i < NR_CPUS; i++) {
if (!cpu_possible(i)) {
for (i = 0; i < NR_CPUS; i++, ptr += size) { __per_cpu_offset[i] = (char*)0 - __per_cpu_start;
continue;
}
__per_cpu_offset[i] = ptr - __per_cpu_start; __per_cpu_offset[i] = ptr - __per_cpu_start;
memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start); memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
ptr += size;
} }
} }
#endif /* !__GENERIC_PER_CPU */ #endif /* !__GENERIC_PER_CPU */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment