* [PATCH] tracefs: Handle synthetic events with dynamic strings as fields
@ 2025-04-11 2:04 Steven Rostedt
0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2025-04-11 2:04 UTC (permalink / raw)
To: Linux Trace Devel
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
Dynamic strings may contain "__data_loc" in their types within the format
files, but "__data_loc" is not an acceptable type for the dynamic_events
file.
For example tracing the latency of interrupts and having the name of the
interrupt be reported:
# sqlhist -e -n irq_lat select irq_handler_entry.name, TIMESTAMP_DELTA_USECS as delta from irq_handler_entry as start join irq_handler_exit as end ON start.irq = end.irq
echo 's:irq_lat __data_loc char name[]; u64 delta;' >> /sys/kernel/tracing/dynamic_events
echo 'hist:keys=irq:__arg_1193_2=name,__arg_1193_3=common_timestamp.usecs' >> /sys/kernel/tracing/events/irq/irq_handler_entry/trigger
echo 'hist:keys=irq:__name_1193_1=$__arg_1193_2,__delta_1193_4=common_timestamp.usecs-$__arg_1193_3:onmatch(irq.irq_handler_entry).trace(irq_lat,$__name_1193_1,$__delta_1193_4)' >> /sys/kernel/tracing/events/irq/irq_handler_exit/trigger
The above writes echo 's:irq_lat __data_loc char name[]; u64 delta;' into
dynamic_events, and the "__data_loc" will cause it to fail. To show this,
adding the '-e' option will execute the command first:
# sqlhist -e -n irq_lat select irq_handler_entry.name, TIMESTAMP_DELTA_USECS as delta from irq_handler_entry as start join irq_handler_exit as end ON start.irq = end.irq
[23109.878734] synthetic_events: error: Invalid type
Command: s:synthetic/irq_lat __data_loc char name[]; u64 delta;
^
The __data_loc caused the write to fail.
Strip the __data_loc off of fields so that it will produce:
# sqlhist -e -n irq_lat select irq_handler_entry.name, TIMESTAMP_DELTA_USECS as delta from irq_handler_entry as start join irq_handler_exit as end ON start.irq = end.irq
echo 's:irq_lat char name[]; u64 delta;' >> /sys/kernel/tracing/dynamic_events
echo 'hist:keys=irq:__arg_1193_2=name,__arg_1193_3=common_timestamp.usecs' >> /sys/kernel/tracing/events/irq/irq_handler_entry/trigger
echo 'hist:keys=irq:__name_1193_1=$__arg_1193_2,__delta_1193_4=common_timestamp.usecs-$__arg_1193_3:onmatch(irq.irq_handler_entry).trace(irq_lat,$__name_1193_1,$__delta_1193_4)' >> /sys/kernel/tracing/events/irq/irq_handler_exit/trigger
And not fail to execute.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
src/tracefs-hist.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
index bfbcd65..d67f8eb 100644
--- a/src/tracefs-hist.c
+++ b/src/tracefs-hist.c
@@ -1068,6 +1068,9 @@ static int alloc_synthetic_event(struct tracefs_synth *synth)
for (i = 0; synth->synthetic_fields && synth->synthetic_fields[i]; i++) {
field = synth->synthetic_fields[i];
+ /* Strip off __data_loc */
+ if (!strncmp(field, "__data_loc ", sizeof("__data_loc ") - 1))
+ field += sizeof("__data_loc ") - 1;
format = tfs_append_string(format, i ? " " : NULL, field);
}
--
2.47.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-04-11 2:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 2:04 [PATCH] tracefs: Handle synthetic events with dynamic strings as fields Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).