10 #include <linux/module.h>
13 #ifdef CONFIG_HOTPLUG_CPU
18 #ifdef CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER
37 .
name =
"percpu_counter",
38 .fixup_free = percpu_counter_fixup_free,
41 static inline void debug_percpu_counter_activate(
struct percpu_counter *fbc)
47 static inline void debug_percpu_counter_deactivate(
struct percpu_counter *fbc)
54 static inline void debug_percpu_counter_activate(
struct percpu_counter *fbc)
56 static inline void debug_percpu_counter_deactivate(
struct percpu_counter *fbc)
80 if (count >= batch || count <= -batch) {
122 debug_percpu_counter_activate(fbc);
124 #ifdef CONFIG_HOTPLUG_CPU
125 INIT_LIST_HEAD(&fbc->list);
126 spin_lock(&percpu_counters_lock);
127 list_add(&fbc->list, &percpu_counters);
128 spin_unlock(&percpu_counters_lock);
139 debug_percpu_counter_deactivate(fbc);
141 #ifdef CONFIG_HOTPLUG_CPU
142 spin_lock(&percpu_counters_lock);
144 spin_unlock(&percpu_counters_lock);
147 fbc->counters =
NULL;
154 static void compute_batch_value(
void)
158 percpu_counter_batch =
max(32, nr*2);
162 unsigned long action,
void *hcpu)
164 #ifdef CONFIG_HOTPLUG_CPU
168 compute_batch_value();
172 cpu = (
unsigned long)hcpu;
173 spin_lock(&percpu_counters_lock);
180 fbc->
count += *pcount;
184 spin_unlock(&percpu_counters_lock);
197 count = percpu_counter_read(fbc);
206 count = percpu_counter_sum(fbc);
209 else if (count < rhs)
216 static int __init percpu_counter_startup(
void)
218 compute_batch_value();