From: David Carlier Date: Thu, 30 Apr 2026 14:41:59 +0000 (+0100) Subject: tracepoint: Add lockdep rcu_is_watching() check to trace_##name##_enabled() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9764e731ef6abacdfc00d914061d4d900e302670;p=thirdparty%2Fkernel%2Flinux.git tracepoint: Add lockdep rcu_is_watching() check to trace_##name##_enabled() The trace_##name##_enabled() static call branch is used when work needs to be done for a tracepoint. It allows that work to be skipped when the tracepoint is not active and still uses the static_branch() of the tracepoint to keep performance. Tracepoints themselves require being called in "RCU watching" locations otherwise races can occur that corrupts things. In order to make sure lockdep triggers at tracepoint locations, the lockdep checks are added to the tracepoint calling location and trigger even if the tracepoint is not enabled. This is done because a poorly placed tracepoint may never be detected if it is never enabled when lockdep is enabled. As trace_##name##_enabled() also prevents the lockdep checks when the tracepoint is disabled add lockdep checks to that as well so that if one is placed in a location that RCU is not watching, it will trigger a lockdep splat even when the tracepoint is not enabled. Cc: Vineeth Pillai (Google) Cc: Mathieu Desnoyers Cc: Masami Hiramatsu Cc: Peter Zijlstra Link: https://patch.msgid.link/20260430144159.10985-1-devnexen@gmail.com Signed-off-by: David Carlier [ Updated the change log ] Signed-off-by: Steven Rostedt --- diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 763eea4d80d8..c29fc57392bb 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -293,6 +293,10 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) static inline bool \ trace_##name##_enabled(void) \ { \ + if (IS_ENABLED(CONFIG_LOCKDEP)) { \ + WARN_ONCE(!rcu_is_watching(), \ + "RCU not watching for tracepoint"); \ + } \ return static_branch_unlikely(&__tracepoint_##name.key);\ }