Release 4.12 include/linux/percpu_counter.h
#ifndef _LINUX_PERCPU_COUNTER_H
#define _LINUX_PERCPU_COUNTER_H
/*
* A simple "approximate counter" for use in ext2 and ext3 superblocks.
*
* WARNING: these things are HUGE. 4 kbytes per counter on 32-way P4.
*/
#include <linux/spinlock.h>
#include <linux/smp.h>
#include <linux/list.h>
#include <linux/threads.h>
#include <linux/percpu.h>
#include <linux/types.h>
#include <linux/gfp.h>
#ifdef CONFIG_SMP
struct percpu_counter {
raw_spinlock_t lock;
s64 count;
#ifdef CONFIG_HOTPLUG_CPU
struct list_head list; /* All percpu_counters are on a list */
#endif
s32 __percpu *counters;
};
extern int percpu_counter_batch;
int __percpu_counter_init(struct percpu_counter *fbc, s64 amount, gfp_t gfp,
struct lock_class_key *key);
#define percpu_counter_init(fbc, value, gfp) \
({ \
static struct lock_class_key __key; \
\
__percpu_counter_init(fbc, value, gfp, &__key); \
})
void percpu_counter_destroy(struct percpu_counter *fbc);
void percpu_counter_set(struct percpu_counter *fbc, s64 amount);
void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch);
s64 __percpu_counter_sum(struct percpu_counter *fbc);
int __percpu_counter_compare(struct percpu_counter *fbc, s64 rhs, s32 batch);
static inline int percpu_counter_compare(struct percpu_counter *fbc, s64 rhs)
{
return __percpu_counter_compare(fbc, rhs, percpu_counter_batch);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Chinner | 25 | 100.00% | 1 | 100.00% |
Total | 25 | 100.00% | 1 | 100.00% |
static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount)
{
__percpu_counter_add(fbc, amount, percpu_counter_batch);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Zijlstra | 23 | 95.83% | 2 | 66.67% |
Eric Dumazet | 1 | 4.17% | 1 | 33.33% |
Total | 24 | 100.00% | 3 | 100.00% |
static inline s64 percpu_counter_sum_positive(struct percpu_counter *fbc)
{
s64 ret = __percpu_counter_sum(fbc);
return ret < 0 ? 0 : ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Zijlstra | 29 | 100.00% | 1 | 100.00% |
Total | 29 | 100.00% | 1 | 100.00% |
static inline s64 percpu_counter_sum(struct percpu_counter *fbc)
{
return __percpu_counter_sum(fbc);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Zijlstra | 18 | 100.00% | 1 | 100.00% |
Total | 18 | 100.00% | 1 | 100.00% |
static inline s64 percpu_counter_read(struct percpu_counter *fbc)
{
return fbc->count;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 16 | 94.12% | 1 | 50.00% |
Mingming Cao | 1 | 5.88% | 1 | 50.00% |
Total | 17 | 100.00% | 2 | 100.00% |
/*
* It is possible for the percpu_counter_read() to return a small negative
* number for some counter which should never be negative.
*
*/
static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
{
s64 ret = fbc->count;
barrier(); /* Prevent reloads of fbc->count */
if (ret >= 0)
return ret;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 31 | 88.57% | 1 | 33.33% |
Mingming Cao | 3 | 8.57% | 1 | 33.33% |
David Shaohua Li | 1 | 2.86% | 1 | 33.33% |
Total | 35 | 100.00% | 3 | 100.00% |
static inline int percpu_counter_initialized(struct percpu_counter *fbc)
{
return (fbc->counters != NULL);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Theodore Y. Ts'o | 21 | 100.00% | 1 | 100.00% |
Total | 21 | 100.00% | 1 | 100.00% |
#else /* !CONFIG_SMP */
struct percpu_counter {
s64 count;
};
static inline int percpu_counter_init(struct percpu_counter *fbc, s64 amount,
gfp_t gfp)
{
fbc->count = amount;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 16 | 59.26% | 1 | 25.00% |
Mingming Cao | 4 | 14.81% | 1 | 25.00% |
Peter Zijlstra | 4 | 14.81% | 1 | 25.00% |
Tejun Heo | 3 | 11.11% | 1 | 25.00% |
Total | 27 | 100.00% | 4 | 100.00% |
static inline void percpu_counter_destroy(struct percpu_counter *fbc)
{
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 11 | 100.00% | 1 | 100.00% |
Total | 11 | 100.00% | 1 | 100.00% |
static inline void percpu_counter_set(struct percpu_counter *fbc, s64 amount)
{
fbc->count = amount;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Zijlstra | 21 | 100.00% | 1 | 100.00% |
Total | 21 | 100.00% | 1 | 100.00% |
static inline int percpu_counter_compare(struct percpu_counter *fbc, s64 rhs)
{
if (fbc->count > rhs)
return 1;
else if (fbc->count < rhs)
return -1;
else
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Tim Chen | 43 | 100.00% | 1 | 100.00% |
Total | 43 | 100.00% | 1 | 100.00% |
static inline int
__percpu_counter_compare(struct percpu_counter *fbc, s64 rhs, s32 batch)
{
return percpu_counter_compare(fbc, rhs);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Chinner | 24 | 92.31% | 1 | 50.00% |
Andrew Morton | 2 | 7.69% | 1 | 50.00% |
Total | 26 | 100.00% | 2 | 100.00% |
static inline void
percpu_counter_add(struct percpu_counter *fbc, s64 amount)
{
preempt_disable();
fbc->count += amount;
preempt_enable();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 23 | 85.19% | 1 | 25.00% |
Peter Zijlstra | 2 | 7.41% | 2 | 50.00% |
Dave Chinner | 2 | 7.41% | 1 | 25.00% |
Total | 27 | 100.00% | 4 | 100.00% |
static inline void
__percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch)
{
percpu_counter_add(fbc, amount);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Anton Blanchard | 25 | 100.00% | 1 | 100.00% |
Total | 25 | 100.00% | 1 | 100.00% |
static inline s64 percpu_counter_read(struct percpu_counter *fbc)
{
return fbc->count;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 16 | 94.12% | 1 | 50.00% |
Mingming Cao | 1 | 5.88% | 1 | 50.00% |
Total | 17 | 100.00% | 2 | 100.00% |
/*
* percpu_counter is intended to track positive numbers. In the UP case the
* number should never be negative.
*/
static inline s64 percpu_counter_read_positive(struct percpu_counter *fbc)
{
return fbc->count;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 16 | 94.12% | 1 | 50.00% |
Mingming Cao | 1 | 5.88% | 1 | 50.00% |
Total | 17 | 100.00% | 2 | 100.00% |
static inline s64 percpu_counter_sum_positive(struct percpu_counter *fbc)
{
return percpu_counter_read_positive(fbc);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 16 | 88.89% | 1 | 33.33% |
Peter Zijlstra | 1 | 5.56% | 1 | 33.33% |
Mingming Cao | 1 | 5.56% | 1 | 33.33% |
Total | 18 | 100.00% | 3 | 100.00% |
static inline s64 percpu_counter_sum(struct percpu_counter *fbc)
{
return percpu_counter_read(fbc);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Zijlstra | 18 | 100.00% | 1 | 100.00% |
Total | 18 | 100.00% | 1 | 100.00% |
static inline int percpu_counter_initialized(struct percpu_counter *fbc)
{
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Theodore Y. Ts'o | 15 | 100.00% | 1 | 100.00% |
Total | 15 | 100.00% | 1 | 100.00% |
#endif /* CONFIG_SMP */
static inline void percpu_counter_inc(struct percpu_counter *fbc)
{
percpu_counter_add(fbc, 1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 18 | 94.74% | 1 | 50.00% |
Peter Zijlstra | 1 | 5.26% | 1 | 50.00% |
Total | 19 | 100.00% | 2 | 100.00% |
static inline void percpu_counter_dec(struct percpu_counter *fbc)
{
percpu_counter_add(fbc, -1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 19 | 95.00% | 1 | 50.00% |
Peter Zijlstra | 1 | 5.00% | 1 | 50.00% |
Total | 20 | 100.00% | 2 | 100.00% |
static inline void percpu_counter_sub(struct percpu_counter *fbc, s64 amount)
{
percpu_counter_add(fbc, -amount);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Peter Zijlstra | 23 | 100.00% | 1 | 100.00% |
Total | 23 | 100.00% | 1 | 100.00% |
#endif /* _LINUX_PERCPU_COUNTER_H */
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 270 | 40.42% | 5 | 18.52% |
Peter Zijlstra | 175 | 26.20% | 10 | 37.04% |
Dave Chinner | 55 | 8.23% | 1 | 3.70% |
Tim Chen | 54 | 8.08% | 1 | 3.70% |
Theodore Y. Ts'o | 36 | 5.39% | 1 | 3.70% |
Anton Blanchard | 25 | 3.74% | 1 | 3.70% |
Mingming Cao | 22 | 3.29% | 1 | 3.70% |
Tejun Heo | 13 | 1.95% | 2 | 7.41% |
Adrian Bunk | 9 | 1.35% | 1 | 3.70% |
Eric Dumazet | 5 | 0.75% | 1 | 3.70% |
David Shaohua Li | 2 | 0.30% | 1 | 3.70% |
Thomas Gleixner | 1 | 0.15% | 1 | 3.70% |
Jesper Dangaard Brouer | 1 | 0.15% | 1 | 3.70% |
Total | 668 | 100.00% | 27 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.