Skip to contentSkip to conversation

tracing: Fix DECLARE_TRACE_CONDITION

PATCH In review Gabriele Monaco 2 participants 3 messages Jan 28, 2025 – Jan 29, 2025 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: Fix DECLARE_TRACE_CONDITION

Commit 287050d39026 ("tracing: Add TRACE_EVENT_CONDITIONAL()") adds macros to define conditional trace events (TRACE_EVENT_CONDITIONAL) and tracepoints (DECLARE_TRACE_CONDITION), but sets up functionality for direct use only for the former.
Any attempt to use DECLARE_TRACE_CONDITION fails the build.

Add preprocessor bits in define_trace.h to allow usage of DECLARE_TRACE_CONDITION just like DECLARE_TRACE.

Fixes 287050d39026 ("tracing: Add TRACE_EVENT_CONDITIONAL()")
---
 include/trace/define_trace.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/trace/define_trace.h +7 -0
index e1c1079f8c8d..ed52d0506c69 100644
@@ -76,6 +76,10 @@
 #define DECLARE_TRACE(name, proto, args)	\
 	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
 
+#undef DECLARE_TRACE_CONDITION
+#define DECLARE_TRACE_CONDITION(name, proto, args, cond)	\
+	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
+
 /* If requested, create helpers for calling these tracepoints from Rust. */
 #ifdef CREATE_RUST_TRACE_POINTS
 #undef DEFINE_RUST_DO_TRACE
@@ -108,6 +112,8 @@
 /* Make all open coded DECLARE_TRACE nops */
 #undef DECLARE_TRACE
 #define DECLARE_TRACE(name, proto, args)
+#undef DECLARE_TRACE_CONDITION
+#define DECLARE_TRACE_CONDITION(name, proto, args, cond)
 
 #ifdef TRACEPOINTS_ENABLED
 #include <trace/trace_events.h>
@@ -129,6 +135,7 @@
 #undef DEFINE_EVENT_CONDITION
 #undef TRACE_HEADER_MULTI_READ
 #undef DECLARE_TRACE
+#undef DECLARE_TRACE_CONDITION
 
 /* Only undef what we defined in this file */
 #ifdef UNDEF_TRACE_INCLUDE_FILE

base-commit: 9c5968db9e625019a0ee5226c7eebef5519d366a

Signature · 1 line
2.48.1
#1 lore raw
Quoted 7 lines · Gabriele Monaco

Commit 287050d39026 ("tracing: Add TRACE_EVENT_CONDITIONAL()") adds macros to define conditional trace events (TRACE_EVENT_CONDITIONAL) and
tracepoints (DECLARE_TRACE_CONDITION), but sets up functionality for direct use only for the former.
Any attempt to use DECLARE_TRACE_CONDITION fails the build.

Quoted 6 lines

Add preprocessor bits in define_trace.h to allow usage of DECLARE_TRACE_CONDITION just like DECLARE_TRACE.

Fixes 287050d39026 ("tracing: Add TRACE_EVENT_CONDITIONAL()")

---

The macro is currently never used, I'm planning to use it in a future patch.
Likewise also DECLARE_TRACE_SYSCALL is never used and would fail the build if used. I'm not sure if the macro would be of use in this way, since it's missing the reg and unreg parameters used in DEFINE_TRACE_SYSCALL, one way not to fail the build is to treat it just like DECLARE_TRACE (as DECLARE_TRACE_CONDITION).
I can prepare this as a patch if it's the intended behaviour:

include/trace/define_trace.h +7 -0
index ed52d0506c69..497a5a2469dc 100644
@@ -80,6 +80,10 @@
 #define DECLARE_TRACE_CONDITION(name, proto, args, cond)	\
 	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
 
+#undef DECLARE_TRACE_SYSCALL
+#define DECLARE_TRACE_SYSCALL(name, proto, args, cond)	\
+	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
+
 /* If requested, create helpers for calling these tracepoints from Rust. */
 #ifdef CREATE_RUST_TRACE_POINTS
 #undef DEFINE_RUST_DO_TRACE
@@ -114,6 +118,8 @@
 #define DECLARE_TRACE(name, proto, args)
 #undef DECLARE_TRACE_CONDITION
 #define DECLARE_TRACE_CONDITION(name, proto, args, cond)
+#undef DECLARE_TRACE_SYSCALL
+#define DECLARE_TRACE_SYSCALL(name, proto, args, cond)
 
 #ifdef TRACEPOINTS_ENABLED
 #include <trace/trace_events.h>
@@ -136,6 +142,7 @@
 #undef TRACE_HEADER_MULTI_READ
 #undef DECLARE_TRACE
 #undef DECLARE_TRACE_CONDITION
+#undef DECLARE_TRACE_SYSCALL
 
 /* Only undef what we defined in this file */
 #ifdef UNDEF_TRACE_INCLUDE_FILE
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Gabriele Monaco
Quoted 11 lines · On Tue, 28 Jan 2025 12:19:26 +0100 Gabriele Monaco <[email protected]> wrote:

Commit 287050d39026 ("tracing: Add TRACE_EVENT_CONDITIONAL()") adds macros to define conditional trace events (TRACE_EVENT_CONDITIONAL) and tracepoints (DECLARE_TRACE_CONDITION), but sets up functionality for direct use only for the former.
Any attempt to use DECLARE_TRACE_CONDITION fails the build.

Add preprocessor bits in define_trace.h to allow usage of DECLARE_TRACE_CONDITION just like DECLARE_TRACE.

Fixes 287050d39026 ("tracing: Add TRACE_EVENT_CONDITIONAL()")

Looks good to me.

Thank you,

Quoted 41 lines
---
 include/trace/define_trace.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/trace/define_trace.h +7 -0
index e1c1079f8c8d..ed52d0506c69 100644
@@ -76,6 +76,10 @@
 #define DECLARE_TRACE(name, proto, args)	\
 	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
 
+#undef DECLARE_TRACE_CONDITION
+#define DECLARE_TRACE_CONDITION(name, proto, args, cond)	\
+	DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
+
 /* If requested, create helpers for calling these tracepoints from Rust. */
 #ifdef CREATE_RUST_TRACE_POINTS
 #undef DEFINE_RUST_DO_TRACE
@@ -108,6 +112,8 @@
 /* Make all open coded DECLARE_TRACE nops */
 #undef DECLARE_TRACE
 #define DECLARE_TRACE(name, proto, args)
+#undef DECLARE_TRACE_CONDITION
+#define DECLARE_TRACE_CONDITION(name, proto, args, cond)
 
 #ifdef TRACEPOINTS_ENABLED
 #include <trace/trace_events.h>
@@ -129,6 +135,7 @@
 #undef DEFINE_EVENT_CONDITION
 #undef TRACE_HEADER_MULTI_READ
 #undef DECLARE_TRACE
+#undef DECLARE_TRACE_CONDITION
 
 /* Only undef what we defined in this file */
 #ifdef UNDEF_TRACE_INCLUDE_FILE

base-commit: 9c5968db9e625019a0ee5226c7eebef5519d366a

Signature · 1 line
2.48.1
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>