diff options
Diffstat (limited to 'include/linux/osq_lock.h')
-rw-r--r-- | include/linux/osq_lock.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/osq_lock.h b/include/linux/osq_lock.h new file mode 100644 index 000000000000..90230d5811c5 --- /dev/null +++ b/include/linux/osq_lock.h | |||
@@ -0,0 +1,27 @@ | |||
1 | #ifndef __LINUX_OSQ_LOCK_H | ||
2 | #define __LINUX_OSQ_LOCK_H | ||
3 | |||
4 | /* | ||
5 | * An MCS like lock especially tailored for optimistic spinning for sleeping | ||
6 | * lock implementations (mutex, rwsem, etc). | ||
7 | */ | ||
8 | |||
9 | #define OSQ_UNLOCKED_VAL (0) | ||
10 | |||
11 | struct optimistic_spin_queue { | ||
12 | /* | ||
13 | * Stores an encoded value of the CPU # of the tail node in the queue. | ||
14 | * If the queue is empty, then it's set to OSQ_UNLOCKED_VAL. | ||
15 | */ | ||
16 | atomic_t tail; | ||
17 | }; | ||
18 | |||
19 | /* Init macro and function. */ | ||
20 | #define OSQ_LOCK_UNLOCKED { ATOMIC_INIT(OSQ_UNLOCKED_VAL) } | ||
21 | |||
22 | static inline void osq_lock_init(struct optimistic_spin_queue *lock) | ||
23 | { | ||
24 | atomic_set(&lock->tail, OSQ_UNLOCKED_VAL); | ||
25 | } | ||
26 | |||
27 | #endif | ||