cregit-Linux how code gets into the kernel

Release 4.7 include/linux/lockref.h

Directory: include/linux
#ifndef __LINUX_LOCKREF_H

#define __LINUX_LOCKREF_H

/*
 * Locked reference counts.
 *
 * These are different from just plain atomic refcounts in that they
 * are atomic with respect to the spinlock that goes with them.  In
 * particular, there can be implementations that don't actually get
 * the spinlock for the common decrement/increment operations, but they
 * still have to check that the operation is done semantically as if
 * the spinlock had been taken (using a cmpxchg operation that covers
 * both the lock and the count word, or using memory transactions, for
 * example).
 */

#include <linux/spinlock.h>
#include <generated/bounds.h>


#define USE_CMPXCHG_LOCKREF \
	(IS_ENABLED(CONFIG_ARCH_USE_CMPXCHG_LOCKREF) && \
         IS_ENABLED(CONFIG_SMP) && SPINLOCK_SIZE <= 4)


struct lockref {
	union {
#if USE_CMPXCHG_LOCKREF
		
aligned_u64 lock_count;
#endif
		struct {
			
spinlock_t lock;
			
int count;
		};
	};
};

extern void lockref_get(struct lockref *);
extern int lockref_put_return(struct lockref *);
extern int lockref_get_not_zero(struct lockref *);
extern int lockref_get_or_lock(struct lockref *);
extern int lockref_put_or_lock(struct lockref *);

extern void lockref_mark_dead(struct lockref *);
extern int lockref_get_not_dead(struct lockref *);

/* Must be called under spinlock for reliable results */

static inline int __lockref_is_dead(const struct lockref *l) { return ((int)l->count < 0); }

Contributors

PersonTokensPropCommitsCommitProp
steven whitehousesteven whitehouse25100.00%1100.00%
Total25100.00%1100.00%

#endif /* __LINUX_LOCKREF_H */

Overall Contributors

PersonTokensPropCommitsCommitProp
linus torvaldslinus torvalds5540.15%555.56%
waiman longwaiman long4532.85%111.11%
steven whitehousesteven whitehouse2618.98%111.11%
peter zijlstrapeter zijlstra107.30%111.11%
kirill a. shutemovkirill a. shutemov10.73%111.11%
Total137100.00%9100.00%
Directory: include/linux
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}