diff options
Diffstat (limited to 'include/linux/percpu_counter.h')
| -rw-r--r-- | include/linux/percpu_counter.h | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h index f5aa593ccf32..3d9f70972cdf 100644 --- a/include/linux/percpu_counter.h +++ b/include/linux/percpu_counter.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include <linux/spinlock.h> | 9 | #include <linux/spinlock.h> |
| 10 | #include <linux/smp.h> | 10 | #include <linux/smp.h> |
| 11 | #include <linux/list.h> | ||
| 11 | #include <linux/threads.h> | 12 | #include <linux/threads.h> |
| 12 | #include <linux/percpu.h> | 13 | #include <linux/percpu.h> |
| 13 | #include <linux/types.h> | 14 | #include <linux/types.h> |
| @@ -17,6 +18,9 @@ | |||
| 17 | struct percpu_counter { | 18 | struct percpu_counter { |
| 18 | spinlock_t lock; | 19 | spinlock_t lock; |
| 19 | s64 count; | 20 | s64 count; |
| 21 | #ifdef CONFIG_HOTPLUG_CPU | ||
| 22 | struct list_head list; /* All percpu_counters are on a list */ | ||
| 23 | #endif | ||
| 20 | s32 *counters; | 24 | s32 *counters; |
| 21 | }; | 25 | }; |
| 22 | 26 | ||
| @@ -26,18 +30,8 @@ struct percpu_counter { | |||
| 26 | #define FBC_BATCH (NR_CPUS*4) | 30 | #define FBC_BATCH (NR_CPUS*4) |
| 27 | #endif | 31 | #endif |
| 28 | 32 | ||
| 29 | static inline void percpu_counter_init(struct percpu_counter *fbc, s64 amount) | 33 | void percpu_counter_init(struct percpu_counter *fbc, s64 amount); |
| 30 | { | 34 | void percpu_counter_destroy(struct percpu_counter *fbc); |
| 31 | spin_lock_init(&fbc->lock); | ||
| 32 | fbc->count = amount; | ||
| 33 | fbc->counters = alloc_percpu(s32); | ||
| 34 | } | ||
| 35 | |||
| 36 | static inline void percpu_counter_destroy(struct percpu_counter *fbc) | ||
| 37 | { | ||
| 38 | free_percpu(fbc->counters); | ||
| 39 | } | ||
| 40 | |||
| 41 | void percpu_counter_mod(struct percpu_counter *fbc, s32 amount); | 35 | void percpu_counter_mod(struct percpu_counter *fbc, s32 amount); |
| 42 | s64 percpu_counter_sum(struct percpu_counter *fbc); | 36 | s64 percpu_counter_sum(struct percpu_counter *fbc); |
| 43 | 37 | ||
