Release 4.7 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 | 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 | peter zijlstra | 23 | 95.83% | 2 | 66.67% |
eric dumazet | 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 | 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 | 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 | andrew morton | 16 | 94.12% | 1 | 50.00% |
mingming cao | 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 | andrew morton | 31 | 88.57% | 1 | 33.33% |
mingming cao | mingming cao | 3 | 8.57% | 1 | 33.33% |
li shaohua | li shaohua | 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 tso | theodore tso | 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 | andrew morton | 16 | 59.26% | 1 | 25.00% |
peter zijlstra | peter zijlstra | 4 | 14.81% | 1 | 25.00% |
mingming cao | mingming cao | 4 | 14.81% | 1 | 25.00% |
tejun heo | 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 | 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 | 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 | 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 | dave chinner | 24 | 92.31% | 1 | 50.00% |
andrew morton | 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 | andrew morton | 23 | 85.19% | 1 | 25.00% |
dave chinner | dave chinner | 2 | 7.41% | 1 | 25.00% |
peter zijlstra | peter zijlstra | 2 | 7.41% | 2 | 50.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 | 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 | andrew morton | 16 | 94.12% | 1 | 50.00% |
mingming cao | 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 | andrew morton | 16 | 94.12% | 1 | 50.00% |
mingming cao | 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 | andrew morton | 16 | 88.89% | 1 | 33.33% |
peter zijlstra | peter zijlstra | 1 | 5.56% | 1 | 33.33% |
mingming cao | 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 | 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 tso | theodore tso | 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 | andrew morton | 18 | 94.74% | 1 | 50.00% |
peter zijlstra | 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 | andrew morton | 19 | 95.00% | 1 | 50.00% |
peter zijlstra | 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 | 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 | andrew morton | 270 | 40.42% | 5 | 18.52% |
peter zijlstra | peter zijlstra | 175 | 26.20% | 10 | 37.04% |
dave chinner | dave chinner | 55 | 8.23% | 1 | 3.70% |
tim chen | tim chen | 54 | 8.08% | 1 | 3.70% |
theodore tso | theodore tso | 36 | 5.39% | 1 | 3.70% |
anton blanchard | anton blanchard | 25 | 3.74% | 1 | 3.70% |
mingming cao | mingming cao | 22 | 3.29% | 1 | 3.70% |
tejun heo | tejun heo | 13 | 1.95% | 2 | 7.41% |
adrian bunk | adrian bunk | 9 | 1.35% | 1 | 3.70% |
eric dumazet | eric dumazet | 5 | 0.75% | 1 | 3.70% |
li shaohua | li shaohua | 2 | 0.30% | 1 | 3.70% |
jesper dangaard brouer | jesper dangaard brouer | 1 | 0.15% | 1 | 3.70% |
thomas gleixner | thomas gleixner | 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.