diff options
Diffstat (limited to 'include/linux/osq_lock.h')
| -rw-r--r-- | include/linux/osq_lock.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/linux/osq_lock.h b/include/linux/osq_lock.h index 90230d5811c5..3a6490e81b28 100644 --- a/include/linux/osq_lock.h +++ b/include/linux/osq_lock.h | |||
| @@ -5,8 +5,11 @@ | |||
| 5 | * An MCS like lock especially tailored for optimistic spinning for sleeping | 5 | * An MCS like lock especially tailored for optimistic spinning for sleeping |
| 6 | * lock implementations (mutex, rwsem, etc). | 6 | * lock implementations (mutex, rwsem, etc). |
| 7 | */ | 7 | */ |
| 8 | 8 | struct optimistic_spin_node { | |
| 9 | #define OSQ_UNLOCKED_VAL (0) | 9 | struct optimistic_spin_node *next, *prev; |
| 10 | int locked; /* 1 if lock acquired */ | ||
| 11 | int cpu; /* encoded CPU # + 1 value */ | ||
| 12 | }; | ||
| 10 | 13 | ||
| 11 | struct optimistic_spin_queue { | 14 | struct optimistic_spin_queue { |
| 12 | /* | 15 | /* |
| @@ -16,6 +19,8 @@ struct optimistic_spin_queue { | |||
| 16 | atomic_t tail; | 19 | atomic_t tail; |
| 17 | }; | 20 | }; |
| 18 | 21 | ||
| 22 | #define OSQ_UNLOCKED_VAL (0) | ||
| 23 | |||
| 19 | /* Init macro and function. */ | 24 | /* Init macro and function. */ |
| 20 | #define OSQ_LOCK_UNLOCKED { ATOMIC_INIT(OSQ_UNLOCKED_VAL) } | 25 | #define OSQ_LOCK_UNLOCKED { ATOMIC_INIT(OSQ_UNLOCKED_VAL) } |
| 21 | 26 | ||
| @@ -24,4 +29,7 @@ static inline void osq_lock_init(struct optimistic_spin_queue *lock) | |||
| 24 | atomic_set(&lock->tail, OSQ_UNLOCKED_VAL); | 29 | atomic_set(&lock->tail, OSQ_UNLOCKED_VAL); |
| 25 | } | 30 | } |
| 26 | 31 | ||
| 32 | extern bool osq_lock(struct optimistic_spin_queue *lock); | ||
| 33 | extern void osq_unlock(struct optimistic_spin_queue *lock); | ||
| 34 | |||
| 27 | #endif | 35 | #endif |
