summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Ilvokhin <d@ilvokhin.com>2026-08-04 07:15:44 +0000
committerPeter Zijlstra <peterz@infradead.org>2026-08-07 17:58:10 +0200
commitb359800c6970cb653d41ed2af18fd8e95dbb822f (patch)
treeeeb7f6dc911982d69ab277296faec8fdaee8043f
parentf7e2cb6d495aa1a88368650970a230b45870859b (diff)
downloadlinux-next-b359800c6970cb653d41ed2af18fd8e95dbb822f.tar.gz
linux-next-b359800c6970cb653d41ed2af18fd8e95dbb822f.zip
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@ilvokhin.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Juergen Gross <jgross@suse.com> Link: https://patch.msgid.link/1c2fcccfb584c075c02890c484f22c76a1948bf1.1785778551.git.d@ilvokhin.com
-rw-r--r--include/trace/events/lock.h10
-rw-r--r--kernel/locking/mutex.c4
2 files changed, 12 insertions, 2 deletions
diff --git a/include/trace/events/lock.h b/include/trace/events/lock.h
index 1ded869cd619..b1d5b18c4514 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 8a85912d7ee6..942a939cee95 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