aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorWaiman Long <longman@redhat.com>2019-05-20 16:59:00 -0400
committerIngo Molnar <mingo@kernel.org>2019-06-17 06:27:54 -0400
commitc71fd893f614f205dbc050d60299cc5496491c19 (patch)
treed1286d64684cbad1bf2ff02c55321bcac040b776 /include
parent69d927bba39517d0980462efc051875b7f4db185 (diff)
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. Signed-off-by: Waiman Long <longman@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tim Chen <tim.c.chen@linux.intel.com> Cc: Will Deacon <will.deacon@arm.com> Cc: huang ying <huang.ying.caritas@gmail.com> Link: https://lkml.kernel.org/r/20190520205918.22251-2-longman@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/rwsem.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index 2ea18a3def04..148983e21d47 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -34,12 +34,12 @@
34 */ 34 */
35struct rw_semaphore { 35struct rw_semaphore {
36 atomic_long_t count; 36 atomic_long_t count;
37#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
38 /* 37 /*
39 * Write owner. Used as a speculative check to see 38 * Write owner or one of the read owners. Can be used as a
40 * if the owner is running on the cpu. 39 * speculative check to see if the owner is running on the cpu.
41 */ 40 */
42 struct task_struct *owner; 41 struct task_struct *owner;
42#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
43 struct optimistic_spin_queue osq; /* spinner MCS lock */ 43 struct optimistic_spin_queue osq; /* spinner MCS lock */
44#endif 44#endif
45 raw_spinlock_t wait_lock; 45 raw_spinlock_t wait_lock;
@@ -73,13 +73,14 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem)
73#endif 73#endif
74 74
75#ifdef CONFIG_RWSEM_SPIN_ON_OWNER 75#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
77#else 77#else
78#define __RWSEM_OPT_INIT(lockname) 78#define __RWSEM_OPT_INIT(lockname)
79#endif 79#endif
80 80
81#define __RWSEM_INITIALIZER(name) \ 81#define __RWSEM_INITIALIZER(name) \
82 { __RWSEM_INIT_COUNT(name), \ 82 { __RWSEM_INIT_COUNT(name), \
83 .owner = NULL, \
83 .wait_list = LIST_HEAD_INIT((name).wait_list), \ 84 .wait_list = LIST_HEAD_INIT((name).wait_list), \
84 .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock) \ 85 .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock) \
85 __RWSEM_OPT_INIT(name) \ 86 __RWSEM_OPT_INIT(name) \