]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tracing: Fix fully-qualified variable reference printing in histograms
authorTom Zanussi <zanussi@kernel.org>
Mon, 13 Apr 2026 22:35:37 +0000 (17:35 -0500)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Tue, 14 Apr 2026 09:28:10 +0000 (05:28 -0400)
The syntax for fully-qualified variable references in histograms is
subsys.event.$var, which is parsed correctly, but not displayed correctly
when printing a histogram spec. The current code puts the $ reference at
the beginning of the fully-qualified variable name i.e. $subsys.event.var,
which is incorrect.

Before:

trigger info: hist:keys=next_comm:vals=hitcount:wakeup_lat=common_timestamp.usecs-$sched.sched_wakeup.ts0: ...

After:

trigger info: hist:keys=next_comm:vals=hitcount:wakeup_lat=common_timestamp.usecs-sched.sched_wakeup.$ts0: ...

Link: https://patch.msgid.link/5dee9a86d062a4dd68c2214f3d90ac93811e1951.1776112478.git.zanussi@kernel.org
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_events_hist.c

index b2b675c7d6638c76da293510e77504bdf3864364..0dbbf6cca9bc947efc68faa1ca5798f36c51021c 100644 (file)
@@ -1361,9 +1361,12 @@ static const char *hist_field_name(struct hist_field *field,
                 field->flags & HIST_FIELD_FL_VAR_REF) {
                if (field->system) {
                        static char full_name[MAX_FILTER_STR_VAL];
+                       static char *fmt;
                        int len;
 
-                       len = snprintf(full_name, sizeof(full_name), "%s.%s.%s",
+                       fmt = field->flags & HIST_FIELD_FL_VAR_REF ? "%s.%s.$%s" : "%s.%s.%s";
+
+                       len = snprintf(full_name, sizeof(full_name), fmt,
                                       field->system, field->event_name,
                                       field->name);
                        if (len >= sizeof(full_name))
@@ -1742,9 +1745,10 @@ static const char *get_hist_field_flags(struct hist_field *hist_field)
 
 static void expr_field_str(struct hist_field *field, char *expr)
 {
-       if (field->flags & HIST_FIELD_FL_VAR_REF)
-               strcat(expr, "$");
-       else if (field->flags & HIST_FIELD_FL_CONST) {
+       if (field->flags & HIST_FIELD_FL_VAR_REF) {
+               if (!field->system)
+                       strcat(expr, "$");
+       } else if (field->flags & HIST_FIELD_FL_CONST) {
                char str[HIST_CONST_DIGITS_MAX];
 
                snprintf(str, HIST_CONST_DIGITS_MAX, "%llu", field->constant);
@@ -6156,7 +6160,8 @@ static void hist_field_print(struct seq_file *m, struct hist_field *hist_field)
        else if (field_name) {
                if (hist_field->flags & HIST_FIELD_FL_VAR_REF ||
                    hist_field->flags & HIST_FIELD_FL_ALIAS)
-                       seq_putc(m, '$');
+                       if (!hist_field->system)
+                               seq_putc(m, '$');
                seq_printf(m, "%s", field_name);
        } else if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP)
                seq_puts(m, "common_timestamp");