cregit-Linux how code gets into the kernel

Release 4.7 include/linux/percpu_counter.h

Directory: include/linux
#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

PersonTokensPropCommitsCommitProp
dave chinnerdave chinner25100.00%1100.00%
Total25100.00%1100.00%


static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount) { __percpu_counter_add(fbc, amount, percpu_counter_batch); }

Contributors

PersonTokensPropCommitsCommitProp
peter zijlstrapeter zijlstra2395.83%266.67%
eric dumazeteric dumazet14.17%133.33%
Total24100.00%3100.00%


static inline s64 percpu_counter_sum_positive(struct percpu_counter *fbc) { s64 ret = __percpu_counter_sum(fbc); return ret < 0 ? 0 : ret; }

Contributors

PersonTokensPropCommitsCommitProp
peter zijlstrapeter zijlstra29100.00%1100.00%
Total29100.00%1100.00%


static inline s64 percpu_counter_sum(struct percpu_counter *fbc) { return __percpu_counter_sum(fbc); }

Contributors

PersonTokensPropCommitsCommitProp
peter zijlstrapeter zijlstra18100.00%1100.00%
Total18100.00%1100.00%


static inline s64 percpu_counter_read(struct percpu_counter *fbc) { return fbc->count; }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton1694.12%150.00%
mingming caomingming cao15.88%150.00%
Total17100.00%2100.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

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton3188.57%133.33%
mingming caomingming cao38.57%133.33%
li shaohuali shaohua12.86%133.33%
Total35100.00%3100.00%


static inline int percpu_counter_initialized(struct percpu_counter *fbc) { return (fbc->counters != NULL); }

Contributors

PersonTokensPropCommitsCommitProp
theodore tsotheodore tso21100.00%1100.00%
Total21100.00%1100.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

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton1659.26%125.00%
peter zijlstrapeter zijlstra414.81%125.00%
mingming caomingming cao414.81%125.00%
tejun heotejun heo311.11%125.00%
Total27100.00%4100.00%


static inline void percpu_counter_destroy(struct percpu_counter *fbc) { }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton11100.00%1100.00%
Total11100.00%1100.00%


static inline void percpu_counter_set(struct percpu_counter *fbc, s64 amount) { fbc->count = amount; }

Contributors

PersonTokensPropCommitsCommitProp
peter zijlstrapeter zijlstra21100.00%1100.00%
Total21100.00%1100.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

PersonTokensPropCommitsCommitProp
tim chentim chen43100.00%1100.00%
Total43100.00%1100.00%


static inline int __percpu_counter_compare(struct percpu_counter *fbc, s64 rhs, s32 batch) { return percpu_counter_compare(fbc, rhs); }

Contributors

PersonTokensPropCommitsCommitProp
dave chinnerdave chinner2492.31%150.00%
andrew mortonandrew morton27.69%150.00%
Total26100.00%2100.00%


static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount) { preempt_disable(); fbc->count += amount; preempt_enable(); }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton2385.19%125.00%
dave chinnerdave chinner27.41%125.00%
peter zijlstrapeter zijlstra27.41%250.00%
Total27100.00%4100.00%


static inline void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch) { percpu_counter_add(fbc, amount); }

Contributors

PersonTokensPropCommitsCommitProp
anton blanchardanton blanchard25100.00%1100.00%
Total25100.00%1100.00%


static inline s64 percpu_counter_read(struct percpu_counter *fbc) { return fbc->count; }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton1694.12%150.00%
mingming caomingming cao15.88%150.00%
Total17100.00%2100.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

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton1694.12%150.00%
mingming caomingming cao15.88%150.00%
Total17100.00%2100.00%


static inline s64 percpu_counter_sum_positive(struct percpu_counter *fbc) { return percpu_counter_read_positive(fbc); }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton1688.89%133.33%
peter zijlstrapeter zijlstra15.56%133.33%
mingming caomingming cao15.56%133.33%
Total18100.00%3100.00%


static inline s64 percpu_counter_sum(struct percpu_counter *fbc) { return percpu_counter_read(fbc); }

Contributors

PersonTokensPropCommitsCommitProp
peter zijlstrapeter zijlstra18100.00%1100.00%
Total18100.00%1100.00%


static inline int percpu_counter_initialized(struct percpu_counter *fbc) { return 1; }

Contributors

PersonTokensPropCommitsCommitProp
theodore tsotheodore tso15100.00%1100.00%
Total15100.00%1100.00%

#endif /* CONFIG_SMP */
static inline void percpu_counter_inc(struct percpu_counter *fbc) { percpu_counter_add(fbc, 1); }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton1894.74%150.00%
peter zijlstrapeter zijlstra15.26%150.00%
Total19100.00%2100.00%


static inline void percpu_counter_dec(struct percpu_counter *fbc) { percpu_counter_add(fbc, -1); }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton1995.00%150.00%
peter zijlstrapeter zijlstra15.00%150.00%
Total20100.00%2100.00%


static inline void percpu_counter_sub(struct percpu_counter *fbc, s64 amount) { percpu_counter_add(fbc, -amount); }

Contributors

PersonTokensPropCommitsCommitProp
peter zijlstrapeter zijlstra23100.00%1100.00%
Total23100.00%1100.00%

#endif /* _LINUX_PERCPU_COUNTER_H */

Overall Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton27040.42%518.52%
peter zijlstrapeter zijlstra17526.20%1037.04%
dave chinnerdave chinner558.23%13.70%
tim chentim chen548.08%13.70%
theodore tsotheodore tso365.39%13.70%
anton blanchardanton blanchard253.74%13.70%
mingming caomingming cao223.29%13.70%
tejun heotejun heo131.95%27.41%
adrian bunkadrian bunk91.35%13.70%
eric dumazeteric dumazet50.75%13.70%
li shaohuali shaohua20.30%13.70%
jesper dangaard brouerjesper dangaard brouer10.15%13.70%
thomas gleixnerthomas gleixner10.15%13.70%
Total668100.00%27100.00%
Directory: include/linux
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}