diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2006-02-05 02:27:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-05 14:06:51 -0500 |
commit | 88a2a4ac6b671a4b0dd5d2d762418904c05f4104 (patch) | |
tree | 8c30052a0d7fadec37c785a42a71b28d0a9c5fcf /mm/page_alloc.c | |
parent | cef5076987dd545ac74f4efcf1c962be8eac34b0 (diff) |
[PATCH] percpu data: only iterate over possible CPUs
percpu_data blindly allocates bootmem memory to store NR_CPUS instances of
cpudata, instead of allocating memory only for possible cpus.
As a preparation for changing that, we need to convert various 0 -> NR_CPUS
loops to use for_each_cpu().
(The above only applies to users of asm-generic/percpu.h. powerpc has gone it
alone and is presently only allocating memory for present CPUs, so it's
currently corrupting memory).
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: James Bottomley <James.Bottomley@steeleye.com>
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>
Cc: Andi Kleen <ak@muc.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 44b4eb4202d9..dde04ff4be31 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -1213,18 +1213,21 @@ static void __get_page_state(struct page_state *ret, int nr, cpumask_t *cpumask) | |||
1213 | { | 1213 | { |
1214 | int cpu = 0; | 1214 | int cpu = 0; |
1215 | 1215 | ||
1216 | memset(ret, 0, sizeof(*ret)); | 1216 | memset(ret, 0, nr * sizeof(unsigned long)); |
1217 | cpus_and(*cpumask, *cpumask, cpu_online_map); | 1217 | cpus_and(*cpumask, *cpumask, cpu_online_map); |
1218 | 1218 | ||
1219 | cpu = first_cpu(*cpumask); | 1219 | cpu = first_cpu(*cpumask); |
1220 | while (cpu < NR_CPUS) { | 1220 | while (cpu < NR_CPUS) { |
1221 | unsigned long *in, *out, off; | 1221 | unsigned long *in, *out, off; |
1222 | 1222 | ||
1223 | if (!cpu_isset(cpu, *cpumask)) | ||
1224 | continue; | ||
1225 | |||
1223 | in = (unsigned long *)&per_cpu(page_states, cpu); | 1226 | in = (unsigned long *)&per_cpu(page_states, cpu); |
1224 | 1227 | ||
1225 | cpu = next_cpu(cpu, *cpumask); | 1228 | cpu = next_cpu(cpu, *cpumask); |
1226 | 1229 | ||
1227 | if (cpu < NR_CPUS) | 1230 | if (likely(cpu < NR_CPUS)) |
1228 | prefetch(&per_cpu(page_states, cpu)); | 1231 | prefetch(&per_cpu(page_states, cpu)); |
1229 | 1232 | ||
1230 | out = (unsigned long *)ret; | 1233 | out = (unsigned long *)ret; |
@@ -1886,8 +1889,7 @@ static void setup_pagelist_highmark(struct per_cpu_pageset *p, | |||
1886 | * not check if the processor is online before following the pageset pointer. | 1889 | * not check if the processor is online before following the pageset pointer. |
1887 | * Other parts of the kernel may not check if the zone is available. | 1890 | * Other parts of the kernel may not check if the zone is available. |
1888 | */ | 1891 | */ |
1889 | static struct per_cpu_pageset | 1892 | static struct per_cpu_pageset boot_pageset[NR_CPUS]; |
1890 | boot_pageset[NR_CPUS]; | ||
1891 | 1893 | ||
1892 | /* | 1894 | /* |
1893 | * Dynamically allocate memory for the | 1895 | * Dynamically allocate memory for the |