[tip: locking/core] tracing/lock: Use TRACE_EVENT_FN() for contended_release

From: tip-bot2 for Dmitry Ilvokhin

Date: Fri Aug 07 2026 - 12:09:46 EST


The following commit has been merged into the locking/core branch of tip:

Commit-ID: b359800c6970cb653d41ed2af18fd8e95dbb822f
Gitweb: https://git.kernel.org/tip/b359800c6970cb653d41ed2af18fd8e95dbb822f
Author: Dmitry Ilvokhin <d@xxxxxxxxxxxx>
AuthorDate: Tue, 04 Aug 2026 07:15:44
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Fri, 07 Aug 2026 17:58:10 +02:00

tracing/lock: Use TRACE_EVENT_FN() for contended_release

queued_spin_unlock() gates its contended_release trace call behind a
static branch, so a NOP sits on the unlock path even while the
tracepoint is disabled. Removing that requires replacing the unlock
implementation only while contended_release is enabled, which needs a
callback when the tracepoint is toggled.

Convert contended_release to TRACE_EVENT_FN() and add weak no-op
arch_contended_release_trace_reg()/arch_contended_release_trace_unreg()
hooks.

The default hooks are empty, so this is a no-op until an architecture
overrides them.

No functional change intended.

Signed-off-by: Dmitry Ilvokhin <d@xxxxxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Acked-by: Juergen Gross <jgross@xxxxxxxx>
Link: https://patch.msgid.link/1c2fcccfb584c075c02890c484f22c76a1948bf1.1785778551.git.d@xxxxxxxxxxxx
---
include/trace/events/lock.h | 10 ++++++++--
kernel/locking/mutex.c | 4 ++++
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/trace/events/lock.h b/include/trace/events/lock.h
index 1ded869..b1d5b18 100644
--- a/include/trace/events/lock.h
+++ b/include/trace/events/lock.h
@@ -137,7 +137,11 @@ TRACE_EVENT(contention_end,
TP_printk("%p (ret=%d)", __entry->lock_addr, __entry->ret)
);

-TRACE_EVENT(contended_release,
+/* kernel/locking/mutex.c */
+int arch_contended_release_trace_reg(void);
+void arch_contended_release_trace_unreg(void);
+
+TRACE_EVENT_FN(contended_release,

TP_PROTO(void *lock),

@@ -151,7 +155,9 @@ TRACE_EVENT(contended_release,
__entry->lock_addr = lock;
),

- TP_printk("%p", __entry->lock_addr)
+ TP_printk("%p", __entry->lock_addr),
+
+ arch_contended_release_trace_reg, arch_contended_release_trace_unreg
);

#endif /* _TRACE_LOCK_H */
diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index 8a85912..942a939 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -1272,6 +1272,10 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(contention_begin);
EXPORT_TRACEPOINT_SYMBOL_GPL(contention_end);
EXPORT_TRACEPOINT_SYMBOL_GPL(contended_release);

+__weak int arch_contended_release_trace_reg(void) { return 0; }
+
+__weak void arch_contended_release_trace_unreg(void) { }
+
/**
* atomic_dec_and_mutex_lock - return holding mutex if we dec to 0
* @cnt: the atomic which we are to dec