diff options
| author | Andrew Morton <akpm@osdl.org> | 2003-12-29 05:45:53 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.osdl.org> | 2003-12-29 05:45:53 -0800 |
| commit | 22565897da1265120070ed8d7f534bddd37f1a69 (patch) | |
| tree | cee4068e9a554b2e81ad9ffa3fe8f40049ab8575 /include | |
| parent | 55e8b1a195a813abfb91fae221c481c0fa77b55f (diff) | |
[PATCH] use alloc_percpu in percpu_counters
From: Martin Hicks <mort@wildopensource.com>
Once NR_CPUS exceeds about 300 ext2 and ext3 will not compile, because the
percpu counters in the superblocks are so huge that they cannot be kmalloced.
Fix this by converting the percpu_counter mechanism to use alloc_percpu()
rather than an NR_CPUS-sized array.
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/percpu_counter.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h index 53c52176c391..594f564e031a 100644 --- a/include/linux/percpu_counter.h +++ b/include/linux/percpu_counter.h @@ -8,17 +8,14 @@ #include <linux/spinlock.h> #include <linux/smp.h> #include <linux/threads.h> +#include <linux/percpu.h> #ifdef CONFIG_SMP -struct __percpu_counter { - long count; -} ____cacheline_aligned; - struct percpu_counter { spinlock_t lock; long count; - struct __percpu_counter counters[NR_CPUS]; + long *counters; }; #if NR_CPUS >= 16 @@ -29,12 +26,14 @@ struct percpu_counter { static inline void percpu_counter_init(struct percpu_counter *fbc) { - int i; - spin_lock_init(&fbc->lock); fbc->count = 0; - for (i = 0; i < NR_CPUS; i++) - fbc->counters[i].count = 0; + fbc->counters = alloc_percpu(long); +} + +static inline void percpu_counter_destroy(struct percpu_counter *fbc) +{ + free_percpu(fbc->counters); } void percpu_counter_mod(struct percpu_counter *fbc, long amount); @@ -69,6 +68,10 @@ static inline void percpu_counter_init(struct percpu_counter *fbc) fbc->count = 0; } +static inline void percpu_counter_destroy(struct percpu_counter *fbc) +{ +} + static inline void percpu_counter_mod(struct percpu_counter *fbc, long amount) { |
