#define FBC_BATCH (NR_CPUS*2)
#define FBC_BATCH (NR_CPUS*4)
The following functions are available to modify approximate per-CPU counters: <percpu_counter.h>
static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount)
static inline void percpu_counter_dec(struct percpu_counter *fbc)
static inline s64 percpu_counter_sum(struct percpu_counter *fbc)
static inline void percpu_counter_set(struct percpu_counter *fbc, s64 amount)
static inline void percpu_counter_inc(struct percpu_counter *fbc)
static inline void percpu_counter_dev(struct percpu_counter *fbc)
□ percpu_counter_add and percpu_counter_dec modify the counter by a given increment or decrement. The change is propagated to the proper counter if the accumulated changes surpass the threshold as given by FBC_BATCH.
□ percpu_counter_read reads the current value of the counter without considering changes made by the individual CPUs.
□ percpu_counter_inc and percpu_counter_inc are shortcuts to, respectively, increment and decrement an approximate counter by 1.
□ percpu_counter_set sets the counter to a specific value.
□ percpu_counter_sum computes the exact value.
Continue reading here: Lock Contention and Fine Grained Locking
Was this article helpful?