From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
James Clark <james.clark@linaro.org>,
Chun-Tse Shao <ctshao@google.com>,
Thomas Falcon <thomas.falcon@intel.com>,
Yang Li <yang.lee@linux.alibaba.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v1 4/4] perf stat-shadow: Display metric-only for 0 counters
Date: Sun, 14 Sep 2025 11:29:00 -0700 [thread overview]
Message-ID: <20250914182900.1960567-5-irogers@google.com> (raw)
In-Reply-To: <20250914182900.1960567-1-irogers@google.com>
0 counters may occur in hypervisor settings but metric-only output is
always expected. This resolves an issue in the "perf stat STD output
linter" test.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/stat-display.c | 3 +++
tools/perf/util/stat-shadow.c | 11 ++++-------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index a67b991f4e81..8a72e019e6c7 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -944,6 +944,9 @@ static bool should_skip_zero_counter(struct perf_stat_config *config,
if (verbose == 0 && counter->skippable && !counter->supported)
return true;
+ /* Metric only counts won't be displayed but the metric wants to be computed. */
+ if (config->metric_only)
+ return false;
/*
* Skip value 0 when enabling --per-thread globally,
* otherwise it will have too many 0 output.
diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c
index abaf6b579bfc..dd3a15b17eb9 100644
--- a/tools/perf/util/stat-shadow.c
+++ b/tools/perf/util/stat-shadow.c
@@ -320,13 +320,10 @@ static void print_instructions(struct perf_stat_config *config,
double max_stalled = max(find_stat(evsel, aggr_idx, STAT_STALLED_CYCLES_FRONT),
find_stat(evsel, aggr_idx, STAT_STALLED_CYCLES_BACK));
- if (cycles) {
- print_metric(config, ctxp, METRIC_THRESHOLD_UNKNOWN, "%7.2f ",
- "insn per cycle", instructions / cycles);
- } else {
- print_metric(config, ctxp, METRIC_THRESHOLD_UNKNOWN, /*fmt=*/NULL,
- "insn per cycle", 0);
- }
+ print_metric(config, ctxp, METRIC_THRESHOLD_UNKNOWN, "%7.2f ",
+ "insn per cycle",
+ fpclassify(cycles) == FP_ZERO ? 0 : instructions / cycles);
+
if (max_stalled && instructions) {
if (out->new_line)
out->new_line(config, ctxp);
--
2.51.0.384.g4c02a37b29-goog
next prev parent reply other threads:[~2025-09-14 18:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-14 18:28 [PATCH v1 0/4] Test fixes and debug logging Ian Rogers
2025-09-14 18:28 ` [PATCH v1 1/4] perf test: Be tolerant of missing json metric none value Ian Rogers
2025-09-14 18:28 ` [PATCH v1 2/4] perf parse-events: Add debug logging to perf_event Ian Rogers
2025-09-14 18:28 ` [PATCH v1 3/4] perf test: Don't fail if user rdpmc returns 0 when disabled Ian Rogers
2025-09-14 18:29 ` Ian Rogers [this message]
2025-09-19 20:45 ` [PATCH v1 0/4] Test fixes and debug logging Arnaldo Carvalho de Melo
2025-09-19 20:46 ` Arnaldo Carvalho de Melo
2025-09-20 15:21 ` Ian Rogers
2025-09-24 9:57 ` Arnaldo Carvalho de Melo
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=20250914182900.1960567-5-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ctshao@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=thomas.falcon@intel.com \
--cc=yang.lee@linux.alibaba.com \
/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).