History

locking/rwsem: Make owner available even if !CONFIG_RWSEM_SPIN_ON_OWNER

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.

Waiman Long committed 7 years ago

Commit c71fd891 parent 69d927b4 files · +10 −32Browse files

Showing the changes to include (1 of 4 files). Show all

Unified · Split

include/linux/rwsem.h+5−4
@@ -34,12 +34,12 @@ · 33 unmodified lines
3434 */
3535 struct rw_semaphore {
3636 atomic_long_t count;
37−#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
3837 /*
39− * Write owner. Used as a speculative check to see
40− * if the owner is running on the cpu.
38+ * Write owner or one of the read owners. Can be used as a
39+ * speculative check to see if the owner is running on the cpu.
4140 */
4241 struct task_struct *owner;
42+#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
4343 struct optimistic_spin_queue osq; /* spinner MCS lock */
4444 #endif
4545 raw_spinlock_t wait_lock;
@@ -73,13 +73,14 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem) · 27 unmodified lines
7373 #endif
7474
7575 #ifdef CONFIG_RWSEM_SPIN_ON_OWNER
76−#define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED, .owner = NULL
76+#define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED
7777 #else
7878 #define __RWSEM_OPT_INIT(lockname)
7979 #endif
8080
8181 #define __RWSEM_INITIALIZER(name) \
8282 { __RWSEM_INIT_COUNT(name), \
83+ .owner = NULL, \
8384 .wait_list = LIST_HEAD_INIT((name).wait_list), \
8485 .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock) \
8586 __RWSEM_OPT_INIT(name) \