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 kernel/locking (2 of 4 files). Show all

Unified · Split

2 files
  1. kernel/locking/rwsem-xadd.c +1 −1
  2. kernel/locking/rwsem.h +0 −23
kernel/locking/rwsem-xadd.c+1−1
@@ -86,8 +86,8 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name, · 85 unmodified lines
8686 atomic_long_set(&sem->count, RWSEM_UNLOCKED_VALUE);
8787 raw_spin_lock_init(&sem->wait_lock);
8888 INIT_LIST_HEAD(&sem->wait_list);
89−#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
9089 sem->owner = NULL;
90+#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
9191 osq_lock_init(&sem->osq);
9292 #endif
9393 }
kernel/locking/rwsem.h+0−23
@@ -61,7 +61,6 @@ · 60 unmodified lines
6161 #define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
6262 #define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
6363
64−#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
6564 /*
6665 * All writes to owner are protected by WRITE_ONCE() to make sure that
6766 * 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
126125 * real owner or one of the real owners. The only exception is when the
127126 * unlock is done by up_read_non_owner().
128127 */
129−#define rwsem_clear_reader_owned rwsem_clear_reader_owned
130128 static inline void rwsem_clear_reader_owned(struct rw_semaphore *sem)
131129 {
132130 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
135133 cmpxchg_relaxed((unsigned long *)&sem->owner, val,
136134 RWSEM_READER_OWNED | RWSEM_ANONYMOUSLY_OWNED);
137135 }
138−#endif
139−
140136 #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
160137 static inline void rwsem_clear_reader_owned(struct rw_semaphore *sem)
161138 {
162139 }