locking/rwsem: Handle handoff bit inheritance
Waiman Long
reviewerPATCH 1/1 locking/rwsem: Handle handoff bit inheritance
When a queue head writer set the handoff bit, it will clear it when the writer is being killed on its way out without acquiring the lock. That is not the case for a queue head reader. The easy thing to do is to let the next waiter inherit the handoff bit especially if the next one is also a reader.
In the case of a writer inheriting the handoff bit, we need to make sure that writer sets its state correctly to avoid leaving the handoff bit dangling if it is killed or interrupted before getting the lock. We also need to make sure that the handoff bit is always cleared when the wait queue is empty to avoid having the handoff bit set with no waiter.
A new lock event is added to keep track of this writer handoff bit inheritance.
--- kernel/locking/lock_events_list.h | 1 + kernel/locking/rwsem.c | 50 +++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 13 deletions(-)
kernel/locking/lock_events_list.h +1 -0
@@ -67,3 +67,4 @@ LOCK_EVENT(rwsem_rlock_handoff) /* # of read lock handoffs */ LOCK_EVENT(rwsem_wlock) /* # of write locks acquired */ LOCK_EVENT(rwsem_wlock_fail) /* # of failed write lock acquisitions */ LOCK_EVENT(rwsem_wlock_handoff) /* # of write lock handoffs */ +LOCK_EVENT(rwsem_inherit_handoff) /* # of handoff inheritance */
kernel/locking/rwsem.c +37 -13
102 lines not on this page · raw message
Signature · 1 line
2.27.0