diff options
Diffstat (limited to 'include/linux/lockref.h')
| -rw-r--r-- | include/linux/lockref.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/linux/lockref.h b/include/linux/lockref.h index f279ed9a9163..c8929c3832db 100644 --- a/include/linux/lockref.h +++ b/include/linux/lockref.h | |||
| @@ -15,10 +15,15 @@ | |||
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include <linux/spinlock.h> | 17 | #include <linux/spinlock.h> |
| 18 | #include <generated/bounds.h> | ||
| 19 | |||
| 20 | #define USE_CMPXCHG_LOCKREF \ | ||
| 21 | (IS_ENABLED(CONFIG_ARCH_USE_CMPXCHG_LOCKREF) && \ | ||
| 22 | IS_ENABLED(CONFIG_SMP) && !BLOATED_SPINLOCKS) | ||
| 18 | 23 | ||
| 19 | struct lockref { | 24 | struct lockref { |
| 20 | union { | 25 | union { |
| 21 | #ifdef CONFIG_CMPXCHG_LOCKREF | 26 | #if USE_CMPXCHG_LOCKREF |
| 22 | aligned_u64 lock_count; | 27 | aligned_u64 lock_count; |
| 23 | #endif | 28 | #endif |
| 24 | struct { | 29 | struct { |
| @@ -36,4 +41,10 @@ extern int lockref_put_or_lock(struct lockref *); | |||
| 36 | extern void lockref_mark_dead(struct lockref *); | 41 | extern void lockref_mark_dead(struct lockref *); |
| 37 | extern int lockref_get_not_dead(struct lockref *); | 42 | extern int lockref_get_not_dead(struct lockref *); |
| 38 | 43 | ||
| 44 | /* Must be called under spinlock for reliable results */ | ||
| 45 | static inline int __lockref_is_dead(const struct lockref *l) | ||
| 46 | { | ||
| 47 | return ((int)l->count < 0); | ||
| 48 | } | ||
| 49 | |||
| 39 | #endif /* __LINUX_LOCKREF_H */ | 50 | #endif /* __LINUX_LOCKREF_H */ |
