From nobody Sat Jun 20 15:18:36 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4790A39BFE3; Mon, 13 Apr 2026 22:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776119746; cv=none; b=hKFVx4teqZbzaiSUeyZjxLQZWocEWFJTGpc2dKOQze0qjBxc5pUVPTtvTociu6epcjl1XyuJKqjmLTE/jUmTXuhSZa5klOkJnKTBKQ6Hiprswh6oiptldF41gnomBDC0daN936so3nzgzYhZntZP4MeUHC3B0YBvqPs9vw4fivI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776119746; c=relaxed/simple; bh=+ZY82Gc+W2fCMb43D85ngNPsUytjGs5PdcXUsYy/KqU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bkKNWIv0+W11Ll6cQVbaUyOIfv7fBbgbXwAaI4KJ7avyQcw31obrph0cTu+C4H8BSYx+ys0WdyzGHGzxYip0ie2sPWg2m1WeqcPQbv1wF1l480zViK+PHATsm6YStOu448gEF3AUQFkYieAwavb82lV2EIWejx5j8taKPTXE4EQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P6ys9UP/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P6ys9UP/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68A19C2BCB4; Mon, 13 Apr 2026 22:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776119745; bh=+ZY82Gc+W2fCMb43D85ngNPsUytjGs5PdcXUsYy/KqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P6ys9UP/KqJTWlxJfZRtg01SbjxcTr4cZHwj5OjrTVQWPIW9m/hml2XV60gZQn6IR pepiuBHPKp82tB2mor0kd+EmLfCsJBC06ZgiFxvtj2h8z9idzb7yRPgaPYxf+c6Avi 5qmdTcMz9+/bqXIsfJ1o9KJ1DlE0iwMHes4rXdzWKUOEhcuVY+66xulKJbJYBZNXZg m0FLbYvC5qMobjVTcsqo0Fg0Uk4GBaLqCYj5qvAEqzJurSvDSG8+Xk4DSuv6vjhY1t 8B1WK+7z1uwpB2aK9Hzw9OmkR/vUY51itKi3PArnXUZjuWnEDU4aTinqrJ3k6ap8z2 NCAjE+OOITowg== From: Tom Zanussi To: rostedt@goodmis.org Cc: pengpeng@iscas.ac.cn, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH 1/2] tracing: Fix fully-qualified variable reference printing in histograms Date: Mon, 13 Apr 2026 17:35:37 -0500 Message-ID: <5dee9a86d062a4dd68c2214f3d90ac93811e1951.1776112478.git.zanussi@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3Dnext_comm:vals=3Dhitcount:wakeup_lat=3Dcommon_tim= estamp.usecs-$sched.sched_wakeup.ts0: ... After: trigger info: hist:keys=3Dnext_comm:vals=3Dhitcount:wakeup_lat=3Dcommon_tim= estamp.usecs-sched.sched_wakeup.$ts0: ... Signed-off-by: Tom Zanussi --- kernel/trace/trace_events_hist.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_h= ist.c index b2b675c7d663..0dbbf6cca9bc 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -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; =20 - len =3D snprintf(full_name, sizeof(full_name), "%s.%s.%s", + fmt =3D field->flags & HIST_FIELD_FL_VAR_REF ? "%s.%s.$%s" : "%s.%s.%s"; + + len =3D snprintf(full_name, sizeof(full_name), fmt, field->system, field->event_name, field->name); if (len >=3D sizeof(full_name)) @@ -1742,9 +1745,10 @@ static const char *get_hist_field_flags(struct hist_= field *hist_field) =20 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]; =20 snprintf(str, HIST_CONST_DIGITS_MAX, "%llu", field->constant); @@ -6156,7 +6160,8 @@ static void hist_field_print(struct seq_file *m, stru= ct 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"); --=20 2.43.0 From nobody Sat Jun 20 15:18:36 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86DD639B94B; Mon, 13 Apr 2026 22:35:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776119747; cv=none; b=DlTqp9B0cGqqZzQazKDBqyrkux9PPkltNqdIDacwONCh5p+lopsCxp1t1wDSFc7r9cmqlIDYfj1knle1Ot4SDn8Lhc7xk3VsliSJrpiCP3Id5ISVM/dixmo04s9YscCC3FR0+irIrOCyLD6hPvN77HniQ2gvXLSLmy8LXgtmHbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776119747; c=relaxed/simple; bh=cJPr/eewsDXnwslvZ/wfB8ztK5whnIbWUfpm+NdLHlo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZuXrJW2ta75PtUxrdE6apcvqR4jCe5qjqE6fVRExNeCm54oz2YvvV0rBQ8kN/DzoPfJYBcSkztBQF1NLBCIpKNU75udevhmhgX6lXsnawSkO69f6OnJ5WD6B3XWJAU52z8SS71VxFMq/Uc/p+uHt4IooFbhyadKRxA6s8lwNsjU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pc0VFNHr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pc0VFNHr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6DE7C2BCB5; Mon, 13 Apr 2026 22:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776119747; bh=cJPr/eewsDXnwslvZ/wfB8ztK5whnIbWUfpm+NdLHlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pc0VFNHrynioaDOlfr6265PkbrpHPIysMu2Y5LnOKPKlS5olZcWrGiFUHNaZacd1z k8TOs5yEILD49kKNWKOZpuLiPAhJwBd+/Vj+VFLIVjEZ5DNxs29g5Drm9IBoM5efGd koQgCMZjIGtY5r8W1K+0ohjLriAdeSKgAev0aiCHV5LG5npiPpMGyxAwo5k5wJCyAT 3AzYofiQmkF3zMKvb1TYDOSZEvCp8fSnbBu5RwD/t9BxFhZVxXFcEOByxr85TIZYh2 j84q3M+BexeQpya4OzLSHHc4rSYP1yKZEUsBXNGIVewN6dOq4lByyQ4DQIvvNjdksM +HByacM3otTMA== From: Tom Zanussi To: rostedt@goodmis.org Cc: pengpeng@iscas.ac.cn, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH 2/2] selftests/ftrace: Add test case for fully-qualified variable references Date: Mon, 13 Apr 2026 17:35:38 -0500 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This test adds a variable (ts0) to two events (sched_waking and sched_wakeup) and uses a fully-qualified variable reference to expicitly choose a particular one (sched_wakeup.$ts0) when calculating the wakeup latency. Signed-off-by: Tom Zanussi --- .../trigger-fully-qualified-var-ref.tc | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-eve= nt/trigger-fully-qualified-var-ref.tc diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trig= ger-fully-qualified-var-ref.tc b/tools/testing/selftests/ftrace/test.d/trig= ger/inter-event/trigger-fully-qualified-var-ref.tc new file mode 100644 index 000000000000..8d12cdd06f1d --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-ful= ly-qualified-var-ref.tc @@ -0,0 +1,34 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: event trigger - test fully-qualified variable reference sup= port +# requires: set_event synthetic_events events/sched/sched_process_fork/his= t ping:program + +fail() { #msg + echo $1 + exit_fail +} + +echo "Test fully-qualified variable reference support" + +echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthe= tic_events +echo 'hist:keys=3Dcomm:ts0=3Dcommon_timestamp.usecs if comm=3D=3D"ping"' >= events/sched/sched_waking/trigger +echo 'hist:keys=3Dcomm:ts0=3Dcommon_timestamp.usecs if comm=3D=3D"ping"' >= events/sched/sched_wakeup/trigger +echo 'hist:keys=3Dnext_comm:wakeup_lat=3Dcommon_timestamp.usecs-sched.sche= d_wakeup.$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_p= id,sched.sched_waking.prio,next_comm) if next_comm=3D=3D"ping"' > events/sc= hed/sched_switch/trigger +echo 'hist:keys=3Dpid,prio,comm:vals=3Dlat:sort=3Dpid,prio' > events/synth= etic/wakeup_latency/trigger + +ping $LOCALHOST -c 3 +if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then + fail "Failed to create inter-event histogram" +fi + +if ! grep -q "synthetic_prio=3Dprio" events/sched/sched_waking/hist; then + fail "Failed to create histogram with fully-qualified variable referen= ce" +fi + +echo '!hist:keys=3Dnext_comm:wakeup_lat=3Dcommon_timestamp.usecs-sched.sch= ed_wakeup.$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_= pid,sched.sched_waking.prio,next_comm) if next_comm=3D=3D"ping"' >> events/= sched/sched_switch/trigger + +if grep -q "synthetic_prio=3Dprio" events/sched/sched_waking/hist; then + fail "Failed to remove histogram with fully-qualified variable referen= ce" +fi + +exit 0 --=20 2.43.0