diff options
Diffstat (limited to 'include/linux/percpu_counter.h')
| -rw-r--r-- | include/linux/percpu_counter.h | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h index a7684a513994..8a7d510ffa9c 100644 --- a/include/linux/percpu_counter.h +++ b/include/linux/percpu_counter.h | |||
| @@ -21,7 +21,7 @@ struct percpu_counter { | |||
| 21 | #ifdef CONFIG_HOTPLUG_CPU | 21 | #ifdef CONFIG_HOTPLUG_CPU |
| 22 | struct list_head list; /* All percpu_counters are on a list */ | 22 | struct list_head list; /* All percpu_counters are on a list */ |
| 23 | #endif | 23 | #endif |
| 24 | s32 *counters; | 24 | s32 __percpu *counters; |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | extern int percpu_counter_batch; | 27 | extern int percpu_counter_batch; |
| @@ -40,6 +40,7 @@ void percpu_counter_destroy(struct percpu_counter *fbc); | |||
| 40 | void percpu_counter_set(struct percpu_counter *fbc, s64 amount); | 40 | void percpu_counter_set(struct percpu_counter *fbc, s64 amount); |
| 41 | void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch); | 41 | void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch); |
| 42 | s64 __percpu_counter_sum(struct percpu_counter *fbc); | 42 | s64 __percpu_counter_sum(struct percpu_counter *fbc); |
| 43 | int percpu_counter_compare(struct percpu_counter *fbc, s64 rhs); | ||
| 43 | 44 | ||
| 44 | static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount) | 45 | static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount) |
| 45 | { | 46 | { |
| @@ -98,8 +99,15 @@ static inline void percpu_counter_set(struct percpu_counter *fbc, s64 amount) | |||
| 98 | fbc->count = amount; | 99 | fbc->count = amount; |
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | #define __percpu_counter_add(fbc, amount, batch) \ | 102 | static inline int percpu_counter_compare(struct percpu_counter *fbc, s64 rhs) |
| 102 | percpu_counter_add(fbc, amount) | 103 | { |
| 104 | if (fbc->count > rhs) | ||
| 105 | return 1; | ||
| 106 | else if (fbc->count < rhs) | ||
| 107 | return -1; | ||
| 108 | else | ||
| 109 | return 0; | ||
| 110 | } | ||
| 103 | 111 | ||
| 104 | static inline void | 112 | static inline void |
| 105 | percpu_counter_add(struct percpu_counter *fbc, s64 amount) | 113 | percpu_counter_add(struct percpu_counter *fbc, s64 amount) |
| @@ -109,6 +117,12 @@ percpu_counter_add(struct percpu_counter *fbc, s64 amount) | |||
| 109 | preempt_enable(); | 117 | preempt_enable(); |
| 110 | } | 118 | } |
| 111 | 119 | ||
| 120 | static inline void | ||
| 121 | __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch) | ||
| 122 | { | ||
| 123 | percpu_counter_add(fbc, amount); | ||
| 124 | } | ||
| 125 | |||
| 112 | static inline s64 percpu_counter_read(struct percpu_counter *fbc) | 126 | static inline s64 percpu_counter_read(struct percpu_counter *fbc) |
| 113 | { | 127 | { |
| 114 | return fbc->count; | 128 | return fbc->count; |
