The owner field in the rw_semaphore structure is used primarily for optimistic spinning. However, identifying the rwsem owner can also be helpful in debugging as well as tracing locking related issues when analyzing crash dump. The owner field may also store state information that can be important to the operation of the rwsem. So the owner field is now made a permanent member of the rw_semaphore structure irrespective of CONFIG_RWSEM_SPIN_ON_OWNER.
Showing the changes to kernel (2 of 4 files). Show all
Unified · Split
| @@ -86,8 +86,8 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name, · 85 unmodified lines | ||
| 86 | 86 | atomic_long_set(&sem->count, RWSEM_UNLOCKED_VALUE); |
| 87 | 87 | raw_spin_lock_init(&sem->wait_lock); |
| 88 | 88 | INIT_LIST_HEAD(&sem->wait_list); |
| 89 | −#ifdef CONFIG_RWSEM_SPIN_ON_OWNER | |
| 90 | 89 | sem->owner = NULL; |
| 90 | +#ifdef CONFIG_RWSEM_SPIN_ON_OWNER | |
| 91 | 91 | osq_lock_init(&sem->osq); |
| 92 | 92 | #endif |
| 93 | 93 | } |
| @@ -61,7 +61,6 @@ · 60 unmodified lines | ||
| 61 | 61 | #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS |
| 62 | 62 | #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) |
| 63 | 63 | |
| 64 | −#ifdef CONFIG_RWSEM_SPIN_ON_OWNER | |
| 65 | 64 | /* |
| 66 | 65 | * All writes to owner are protected by WRITE_ONCE() to make sure that |
| 67 | 66 | * store tearing can't happen as optimistic spinners may read and use |
| @@ -126,7 +125,6 @@ static inline bool rwsem_has_anonymous_owner(struct task_struct *owner) · 58 unmodified lines | ||
| 126 | 125 | * real owner or one of the real owners. The only exception is when the |
| 127 | 126 | * unlock is done by up_read_non_owner(). |
| 128 | 127 | */ |
| 129 | −#define rwsem_clear_reader_owned rwsem_clear_reader_owned | |
| 130 | 128 | static inline void rwsem_clear_reader_owned(struct rw_semaphore *sem) |
| 131 | 129 | { |
| 132 | 130 | unsigned long val = (unsigned long)current | RWSEM_READER_OWNED |
| @@ -135,28 +133,7 @@ static inline void rwsem_clear_reader_owned(struct rw_semaphore *sem) · 2 unmodified lines | ||
| 135 | 133 | cmpxchg_relaxed((unsigned long *)&sem->owner, val, |
| 136 | 134 | RWSEM_READER_OWNED | RWSEM_ANONYMOUSLY_OWNED); |
| 137 | 135 | } |
| 138 | −#endif | |
| 139 | − | |
| 140 | 136 | #else |
| 141 | −static inline void rwsem_set_owner(struct rw_semaphore *sem) | |
| 142 | −{ | |
| 143 | −} | |
| 144 | − | |
| 145 | −static inline void rwsem_clear_owner(struct rw_semaphore *sem) | |
| 146 | −{ | |
| 147 | −} | |
| 148 | − | |
| 149 | −static inline void __rwsem_set_reader_owned(struct rw_semaphore *sem, | |
| 150 | − struct task_struct *owner) | |
| 151 | −{ | |
| 152 | −} | |
| 153 | − | |
| 154 | −static inline void rwsem_set_reader_owned(struct rw_semaphore *sem) | |
| 155 | −{ | |
| 156 | −} | |
| 157 | −#endif | |
| 158 | − | |
| 159 | −#ifndef rwsem_clear_reader_owned | |
| 160 | 137 | static inline void rwsem_clear_reader_owned(struct rw_semaphore *sem) |
| 161 | 138 | { |
| 162 | 139 | } |