1 #ifndef _LINUX_PERCPU_COUNTER_H
2 #define _LINUX_PERCPU_COUNTER_H
11 #include <linux/list.h>
14 #include <linux/types.h>
21 #ifdef CONFIG_HOTPLUG_CPU
27 extern int percpu_counter_batch;
32 #define percpu_counter_init(fbc, value) \
34 static struct lock_class_key __key; \
36 __percpu_counter_init(fbc, value, &__key); \
53 return ret < 0 ? 0 :
ret;
81 static inline int percpu_counter_initialized(
struct percpu_counter *fbc)
83 return (fbc->counters !=
NULL);
109 if (fbc->
count > rhs)
111 else if (fbc->
count < rhs)
121 fbc->
count += amount;
128 percpu_counter_add(fbc, amount);
147 return percpu_counter_read_positive(fbc);
152 return percpu_counter_read(fbc);
155 static inline int percpu_counter_initialized(
struct percpu_counter *fbc)
164 percpu_counter_add(fbc, 1);
169 percpu_counter_add(fbc, -1);
174 percpu_counter_add(fbc, -amount);