From: Steven Rostedt <rostedt@goodmis.org>
To: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: [PATCH] tracefs: Handle synthetic events with dynamic strings as fields
Date: Thu, 10 Apr 2025 22:04:39 -0400 [thread overview]
Message-ID: <20250410220439.14b81af3@gandalf.local.home> (raw)
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
reply other threads:[~2025-04-11 2:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250410220439.14b81af3@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).