s390/rwlock: Add contention tracepoints to rwlock slowpath
PATCH v2 1/1 s390/rwlock: Add contention tracepoints to rwlock slowpath
Instrument arch_read_lock_wait() and arch_write_lock_wait() with trace_contention_begin() and trace_contention_end().
These tracepoints are used by lock contention analysis tools such as perf lock contention to identify contended rwlocks and measure wait times. The generic implementation in kernel/locking/qrwlock.c already emits the same events from its read and write slowpaths.
For arch_read_lock_wait(), the in_interrupt() fast-path is intentionally left outside the tracepoint scope. That path spins without entering the wait queue, so it does not represent queue-based contention and its duration is not comparable to the normal slowpath. This matches the behaviour of queued_read_lock_slowpath() in qrwlock.c.
The include for <trace/events/lock.h> is already present from commit ffa796cc1f45 ("s390/spinlock: Add contention tracepoints to lock slowpath").
---
v1 -> v2:
- Fix tracepoint placement in arch_read_lock_wait() to avoid recursion deadlocks.
arch/s390/lib/spinlock.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/s390/lib/spinlock.c +4 -0
@@ -318,6 +318,7 @@ void arch_read_lock_wait(arch_rwlock_t *rw)/* Remove this reader again to allow recursive read locking */ __atomic_add_const (-1 , &rw->cnts); +trace_contention_begin (rw,LCB_F_SPIN |LCB_F_READ );/* Put the reader into the wait queue */ arch_spin_lock (&rw->wait);/* Now add this reader to the count value again */
@@ -326,6 +327,7 @@ void arch_read_lock_wait(arch_rwlock_t *rw)while (READ_ONCE (rw->cnts) &0x10000 )barrier ();arch_spin_unlock (&rw->wait); +trace_contention_end (rw,0 ); }EXPORT_SYMBOL (arch_read_lock_wait);
@@ -333,6 +335,7 @@ void arch_write_lock_wait(arch_rwlock_t *rw) {int old; +trace_contention_begin (rw,LCB_F_SPIN |LCB_F_WRITE );/* Add this CPU to the write waiters */ __atomic_add (0x20000 , &rw->cnts);
@@ -349,6 +352,7 @@ void arch_write_lock_wait(arch_rwlock_t *rw) }arch_spin_unlock (&rw->wait); +trace_contention_end (rw,0 ); }EXPORT_SYMBOL (arch_write_lock_wait);
--
2.53.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 14 lines
Instrument
arch_read_lock_wait()andarch_write_lock_wait()withtrace_contention_begin()andtrace_contention_end().These tracepoints are used by lock contention analysis tools such as perf lock contention to identify contended rwlocks and measure wait times. The generic implementation in
kernel/locking/qrwlock.calready emits the same events from its read and write slowpaths.For
arch_read_lock_wait(), thein_interrupt()fast-path is intentionally left outside the tracepoint scope. That path spins without entering the wait queue, so it does not represent queue-based contention and its duration is not comparable to the normal slowpath. This matches the behaviour ofqueued_read_lock_slowpath()inqrwlock.c.
Quoted 5 lines
The include for <
trace/events/lock.h> is already present from commitffa796cc1f45("s390/spinlock: Add contention tracepoints to lock slowpath").Signed-off-by Jan Polensky <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 18 lines · Jan Polensky
Instrument
arch_read_lock_wait()andarch_write_lock_wait()withtrace_contention_begin()andtrace_contention_end().These tracepoints are used by lock contention analysis tools such as perf lock contention to identify contended rwlocks and measure wait times. The generic implementation in
kernel/locking/qrwlock.calready emits the same events from its read and write slowpaths.For
arch_read_lock_wait(), thein_interrupt()fast-path is intentionally left outside the tracepoint scope. That path spins without entering the wait queue, so it does not represent queue-based contention and its duration is not comparable to the normal slowpath. This matches the behaviour ofqueued_read_lock_slowpath()inqrwlock.c.The include for <
trace/events/lock.h> is already present from commitffa796cc1f45("s390/spinlock: Add contention tracepoints to lock slowpath").
Quoted 7 lines
Signed-off-by Jan Polensky <[email protected]>---
v1 -> v2:
- Fix tracepoint placement inarch_read_lock_wait()to avoid recursion deadlocks.arch/s390/lib/spinlock.c | 4 ++++ 1 file changed, 4 insertions(+)
Applied, thanks!