Lines Matching refs:fbc
24 struct percpu_counter *fbc = addr;
28 percpu_counter_destroy(fbc);
29 debug_object_free(fbc, &percpu_counter_debug_descr);
41 static inline void debug_percpu_counter_activate(struct percpu_counter *fbc)
43 debug_object_init(fbc, &percpu_counter_debug_descr);
44 debug_object_activate(fbc, &percpu_counter_debug_descr);
47 static inline void debug_percpu_counter_deactivate(struct percpu_counter *fbc)
49 debug_object_deactivate(fbc, &percpu_counter_debug_descr);
50 debug_object_free(fbc, &percpu_counter_debug_descr);
54 static inline void debug_percpu_counter_activate(struct percpu_counter *fbc)
56 static inline void debug_percpu_counter_deactivate(struct percpu_counter *fbc)
60 void percpu_counter_set(struct percpu_counter *fbc, s64 amount)
65 raw_spin_lock_irqsave(&fbc->lock, flags);
67 s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
70 fbc->count = amount;
71 raw_spin_unlock_irqrestore(&fbc->lock, flags);
83 * the this_cpu_add(), and the interrupt updates this_cpu(*fbc->counters),
87 void percpu_counter_add_batch(struct percpu_counter *fbc, s64 amount, s32 batch)
93 count = __this_cpu_read(*fbc->counters) + amount;
95 raw_spin_lock(&fbc->lock);
96 fbc->count += count;
97 __this_cpu_sub(*fbc->counters, count - amount);
98 raw_spin_unlock(&fbc->lock);
100 this_cpu_add(*fbc->counters, amount);
112 void percpu_counter_sync(struct percpu_counter *fbc)
117 raw_spin_lock_irqsave(&fbc->lock, flags);
118 count = __this_cpu_read(*fbc->counters);
119 fbc->count += count;
120 __this_cpu_sub(*fbc->counters, count);
121 raw_spin_unlock_irqrestore(&fbc->lock, flags);
137 s64 __percpu_counter_sum(struct percpu_counter *fbc)
143 raw_spin_lock_irqsave(&fbc->lock, flags);
144 ret = fbc->count;
146 s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
149 raw_spin_unlock_irqrestore(&fbc->lock, flags);
154 int __percpu_counter_init_many(struct percpu_counter *fbc, s64 amount,
167 fbc[0].counters = NULL;
172 raw_spin_lock_init(&fbc[i].lock);
173 lockdep_set_class(&fbc[i].lock, key);
175 INIT_LIST_HEAD(&fbc[i].list);
177 fbc[i].count = amount;
178 fbc[i].counters = (void *)counters + (i * counter_size);
180 debug_percpu_counter_activate(&fbc[i]);
186 list_add(&fbc[i].list, &percpu_counters);
193 void percpu_counter_destroy_many(struct percpu_counter *fbc, u32 nr_counters)
198 if (WARN_ON_ONCE(!fbc))
201 if (!fbc[0].counters)
205 debug_percpu_counter_deactivate(&fbc[i]);
210 list_del(&fbc[i].list);
214 free_percpu(fbc[0].counters);
217 fbc[i].counters = NULL;
235 struct percpu_counter *fbc;
240 list_for_each_entry(fbc, &percpu_counters, list) {
243 raw_spin_lock(&fbc->lock);
244 pcount = per_cpu_ptr(fbc->counters, cpu);
245 fbc->count += *pcount;
247 raw_spin_unlock(&fbc->lock);
258 int __percpu_counter_compare(struct percpu_counter *fbc, s64 rhs, s32 batch)
262 count = percpu_counter_read(fbc);
271 count = percpu_counter_sum(fbc);