cregit-Linux how code gets into the kernel

Release 4.12 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 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 Zijlstra2395.83%266.67%
Eric 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 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 Zijlstra18100.00%1100.00%
Total18100.00%1100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Andrew Morton1694.12%150.00%
Mingming 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 Morton3188.57%133.33%
Mingming Cao38.57%133.33%
David Shaohua Li12.86%133.33%
Total35100.00%3100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Theodore Y. Ts'o21100.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 Morton1659.26%125.00%
Mingming Cao414.81%125.00%
Peter Zijlstra414.81%125.00%
Tejun Heo311.11%125.00%
Total27100.00%4100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Andrew 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 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 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 Chinner2492.31%150.00%
Andrew 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 Morton2385.19%125.00%
Peter Zijlstra27.41%250.00%
Dave Chinner27.41%125.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 Blanchard25100.00%1100.00%
Total25100.00%1100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Andrew Morton1694.12%150.00%
Mingming 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 Morton1694.12%150.00%
Mingming 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 Morton1688.89%133.33%
Peter Zijlstra15.56%133.33%
Mingming 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 Zijlstra18100.00%1100.00%
Total18100.00%1100.00%


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

Contributors

PersonTokensPropCommitsCommitProp
Theodore Y. Ts'o15100.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 Morton1894.74%150.00%
Peter 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 Morton1995.00%150.00%
Peter 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 Zijlstra23100.00%1100.00%
Total23100.00%1100.00%

#endif /* _LINUX_PERCPU_COUNTER_H */

Overall Contributors

PersonTokensPropCommitsCommitProp
Andrew Morton27040.42%518.52%
Peter Zijlstra17526.20%1037.04%
Dave Chinner558.23%13.70%
Tim Chen548.08%13.70%
Theodore Y. Ts'o365.39%13.70%
Anton Blanchard253.74%13.70%
Mingming Cao223.29%13.70%
Tejun Heo131.95%27.41%
Adrian Bunk91.35%13.70%
Eric Dumazet50.75%13.70%
David Shaohua Li20.30%13.70%
Thomas Gleixner10.15%13.70%
Jesper Dangaard Brouer10.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.
Created with cregit.