* [PATCH] tracepoint: add lockdep rcu_is_watching() check to trace_call__##name()
@ 2026-04-30 5:35 David Carlier
2026-04-30 13:35 ` Steven Rostedt
2026-04-30 14:41 ` [PATCH v2] tracepoint: add lockdep rcu_is_watching() check to trace_##name##_enabled() David Carlier
0 siblings, 2 replies; 4+ messages in thread
From: David Carlier @ 2026-04-30 5:35 UTC (permalink / raw)
To: linux-trace-kernel
Cc: linux-kernel, David Carlier, Vineeth Pillai (Google),
Mathieu Desnoyers, Masami Hiramatsu, Peter Zijlstra,
Steven Rostedt
trace_call__##name() was added by commit 677a3d82b640 ("tracepoint: Add
trace_call__##name() API") to let callers that already gate on
trace_##name##_enabled() skip the redundant static_branch_unlikely()
re-evaluation. The changelog states that the new helper retains the
LOCKDEP RCU-watching assertion carried by trace_##name(), but the
WARN_ONCE() was omitted from both definitions.
Without it, sites converted from trace_foo(args) to trace_call__foo(args)
lose the WARN_ONCE(!rcu_is_watching()) coverage under CONFIG_LOCKDEP when
the tracepoint is enabled - the case that commit c2679254b9c9 ("tracing:
Make tracepoint lockdep check actually test something") added the warning
for.
Mirror the same block in both trace_call__##name() bodies, gated by
(cond) in __DECLARE_TRACE to match its trace_##name() and ungated in
__DECLARE_TRACE_SYSCALL.
Fixes: 677a3d82b640 ("tracepoint: Add trace_call__##name() API")
Cc: Vineeth Pillai (Google) <vineeth@bitbyteword.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: David Carlier <devnexen@gmail.com>
---
include/linux/tracepoint.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 578e520b6ee6..048e0035d4fa 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -318,6 +318,10 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
static inline void trace_call__##name(proto) \
{ \
__do_trace_##name(args); \
+ if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \
+ WARN_ONCE(!rcu_is_watching(), \
+ "RCU not watching for tracepoint"); \
+ } \
}
#define __DECLARE_TRACE_SYSCALL(name, proto, args, data_proto) \
@@ -342,6 +346,10 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
{ \
might_fault(); \
__do_trace_##name(args); \
+ if (IS_ENABLED(CONFIG_LOCKDEP)) { \
+ WARN_ONCE(!rcu_is_watching(), \
+ "RCU not watching for tracepoint"); \
+ } \
}
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tracepoint: add lockdep rcu_is_watching() check to trace_call__##name()
2026-04-30 5:35 [PATCH] tracepoint: add lockdep rcu_is_watching() check to trace_call__##name() David Carlier
@ 2026-04-30 13:35 ` Steven Rostedt
2026-04-30 14:41 ` [PATCH v2] tracepoint: add lockdep rcu_is_watching() check to trace_##name##_enabled() David Carlier
1 sibling, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2026-04-30 13:35 UTC (permalink / raw)
To: David Carlier
Cc: linux-trace-kernel, linux-kernel, Vineeth Pillai (Google),
Mathieu Desnoyers, Masami Hiramatsu, Peter Zijlstra
On Thu, 30 Apr 2026 06:35:10 +0100
David Carlier <devnexen@gmail.com> wrote:
> Without it, sites converted from trace_foo(args) to trace_call__foo(args)
> lose the WARN_ONCE(!rcu_is_watching()) coverage under CONFIG_LOCKDEP when
> the tracepoint is enabled - the case that commit c2679254b9c9 ("tracing:
> Make tracepoint lockdep check actually test something") added the warning
> for.
>
> Mirror the same block in both trace_call__##name() bodies, gated by
> (cond) in __DECLARE_TRACE to match its trace_##name() and ungated in
> __DECLARE_TRACE_SYSCALL.
If it gets called without rcu watching, the rcu dereference in
__DO_TRACE_CALL() will trigger.
No need to add the warning here. The reason the trace_foo() had it, was to
trigger when the tracepoint WASN'T enabled.
Now, perhaps where the warning should go, is in the trace_foo_enabled()
code.
-- Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] tracepoint: add lockdep rcu_is_watching() check to trace_##name##_enabled()
2026-04-30 5:35 [PATCH] tracepoint: add lockdep rcu_is_watching() check to trace_call__##name() David Carlier
2026-04-30 13:35 ` Steven Rostedt
@ 2026-04-30 14:41 ` David Carlier
2026-04-30 20:01 ` Steven Rostedt
1 sibling, 1 reply; 4+ messages in thread
From: David Carlier @ 2026-04-30 14:41 UTC (permalink / raw)
To: linux-trace-kernel
Cc: linux-kernel, rostedt, mhiramat, mathieu.desnoyers, peterz,
vineeth, David Carlier
trace_call__##name() was added by commit 677a3d82b640 ("tracepoint: Add
trace_call__##name() API") for callers that already gate on
trace_##name##_enabled(), letting them skip the redundant
static_branch_unlikely() re-evaluation. The LOCKDEP rcu_is_watching()
WARN_ONCE() that trace_##name() carries on the disabled path was not
mirrored, so the cold-path coverage added by commit c2679254b9c9
("tracing: Make tracepoint lockdep check actually test something") is
lost for trace_call__##name() callers when the tracepoint is disabled.
When the tracepoint is enabled, the rcu_dereference inside
__DO_TRACE_CALL() already trips under PROVE_RCU, so the warning is
only needed on the !enabled path. The natural place is the gate that
trace_call__##name() callers consult: trace_##name##_enabled().
Fixes: 677a3d82b640 ("tracepoint: Add trace_call__##name() API")
Cc: Vineeth Pillai (Google) <vineeth@bitbyteword.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: David Carlier <devnexen@gmail.com>
---
include/linux/tracepoint.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 578e520b6ee6..3b3ab19c2627 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);\
}
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] tracepoint: add lockdep rcu_is_watching() check to trace_##name##_enabled()
2026-04-30 14:41 ` [PATCH v2] tracepoint: add lockdep rcu_is_watching() check to trace_##name##_enabled() David Carlier
@ 2026-04-30 20:01 ` Steven Rostedt
0 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2026-04-30 20:01 UTC (permalink / raw)
To: David Carlier
Cc: linux-trace-kernel, linux-kernel, mhiramat, mathieu.desnoyers,
peterz, vineeth
On Thu, 30 Apr 2026 15:41:59 +0100
David Carlier <devnexen@gmail.com> wrote:
> trace_call__##name() was added by commit 677a3d82b640 ("tracepoint: Add
> trace_call__##name() API") for callers that already gate on
> trace_##name##_enabled(), letting them skip the redundant
> static_branch_unlikely() re-evaluation. The LOCKDEP rcu_is_watching()
> WARN_ONCE() that trace_##name() carries on the disabled path was not
> mirrored, so the cold-path coverage added by commit c2679254b9c9
> ("tracing: Make tracepoint lockdep check actually test something") is
> lost for trace_call__##name() callers when the tracepoint is disabled.
>
> When the tracepoint is enabled, the rcu_dereference inside
> __DO_TRACE_CALL() already trips under PROVE_RCU, so the warning is
> only needed on the !enabled path. The natural place is the gate that
> trace_call__##name() callers consult: trace_##name##_enabled().
>
> Fixes: 677a3d82b640 ("tracepoint: Add trace_call__##name() API")
Thanks, but I'm 86'ing the Fixes tag. The above commit has absolutely
nothing to do with this patch. This issue was there from the beginning of
having the trace_*_enabled() macro. This isn't a fix.
I'll modify the change log to be more accurate as well.
-- Steve
> Cc: Vineeth Pillai (Google) <vineeth@bitbyteword.org>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: David Carlier <devnexen@gmail.com>
> ---
> include/linux/tracepoint.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
> index 578e520b6ee6..3b3ab19c2627 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);\
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-30 20:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 5:35 [PATCH] tracepoint: add lockdep rcu_is_watching() check to trace_call__##name() David Carlier
2026-04-30 13:35 ` Steven Rostedt
2026-04-30 14:41 ` [PATCH v2] tracepoint: add lockdep rcu_is_watching() check to trace_##name##_enabled() David Carlier
2026-04-30 20:01 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox