* [PATCH v2 1/4] perf test: Be tolerant of missing json metric none value
2025-11-12 19:53 [PATCH v2 0/4] Test fixes and debug logging Ian Rogers
@ 2025-11-12 19:53 ` Ian Rogers
2025-11-12 19:53 ` [PATCH v2 2/4] perf parse-events: Add debug logging to perf_event Ian Rogers
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Ian Rogers @ 2025-11-12 19:53 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, Kan Liang, James Clark, Chun-Tse Shao,
Thomas Falcon, Yang Li, linux-perf-users, linux-kernel
print_metric_only_json and print_metric_end in stat-display.c may
create a metric value of "none" which fails validation as isfloat. Add
a helper to properly validate metric numeric values.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/tests/shell/lib/perf_json_output_lint.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/perf/tests/shell/lib/perf_json_output_lint.py b/tools/perf/tests/shell/lib/perf_json_output_lint.py
index 1369baaa0361..dafbde56cc76 100644
--- a/tools/perf/tests/shell/lib/perf_json_output_lint.py
+++ b/tools/perf/tests/shell/lib/perf_json_output_lint.py
@@ -43,6 +43,9 @@ def isint(num):
def is_counter_value(num):
return isfloat(num) or num == '<not counted>' or num == '<not supported>'
+def is_metric_value(num):
+ return isfloat(num) or num == 'none'
+
def check_json_output(expected_items):
checks = {
'counters': lambda x: isfloat(x),
@@ -57,7 +60,7 @@ def check_json_output(expected_items):
'event-runtime': lambda x: isfloat(x),
'interval': lambda x: isfloat(x),
'metric-unit': lambda x: True,
- 'metric-value': lambda x: isfloat(x),
+ 'metric-value': lambda x: is_metric_value(x),
'metric-threshold': lambda x: x in ['unknown', 'good', 'less good', 'nearly bad', 'bad'],
'metricgroup': lambda x: True,
'node': lambda x: True,
--
2.51.2.1041.gc1ab5b90ca-goog
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v2 2/4] perf parse-events: Add debug logging to perf_event
2025-11-12 19:53 [PATCH v2 0/4] Test fixes and debug logging Ian Rogers
2025-11-12 19:53 ` [PATCH v2 1/4] perf test: Be tolerant of missing json metric none value Ian Rogers
@ 2025-11-12 19:53 ` Ian Rogers
2025-11-12 19:53 ` [PATCH v2 3/4] perf test: Don't fail if user rdpmc returns 0 when disabled Ian Rogers
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Ian Rogers @ 2025-11-12 19:53 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, Kan Liang, James Clark, Chun-Tse Shao,
Thomas Falcon, Yang Li, linux-perf-users, linux-kernel
If verbose is enabled and parse_event is called, typically by tests,
log failures.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/parse-events.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 0c0dc20b1c13..e522082c5a21 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2236,6 +2236,8 @@ int parse_event(struct evlist *evlist, const char *str)
parse_events_error__init(&err);
ret = parse_events(evlist, str, &err);
+ if (ret && verbose > 0)
+ parse_events_error__print(&err, str);
parse_events_error__exit(&err);
return ret;
}
--
2.51.2.1041.gc1ab5b90ca-goog
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v2 3/4] perf test: Don't fail if user rdpmc returns 0 when disabled
2025-11-12 19:53 [PATCH v2 0/4] Test fixes and debug logging Ian Rogers
2025-11-12 19:53 ` [PATCH v2 1/4] perf test: Be tolerant of missing json metric none value Ian Rogers
2025-11-12 19:53 ` [PATCH v2 2/4] perf parse-events: Add debug logging to perf_event Ian Rogers
@ 2025-11-12 19:53 ` Ian Rogers
2025-11-12 19:53 ` [PATCH v2 4/4] perf stat: Display metric-only for 0 counters Ian Rogers
2025-11-18 1:35 ` [PATCH v2 0/4] Test fixes and debug logging Namhyung Kim
4 siblings, 0 replies; 6+ messages in thread
From: Ian Rogers @ 2025-11-12 19:53 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, Kan Liang, James Clark, Chun-Tse Shao,
Thomas Falcon, Yang Li, linux-perf-users, linux-kernel
In certain hypervisor set ups the value 0 may be returned but this is
only erroneous if the user rdpmc isn't disabled.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/tests/mmap-basic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index 3c89d3001887..3313c236104e 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -322,7 +322,7 @@ static int test_stat_user_read(u64 event, enum user_read_state enabled)
}
perf_evsel__read(evsel, 0, 0, &counts);
- if (counts.val == 0) {
+ if (rdpmc_supported && counts.val == 0) {
pr_err("User space counter reading for PMU %s [Failed read]\n", pmu->name);
ret = TEST_FAIL;
goto cleanup;
--
2.51.2.1041.gc1ab5b90ca-goog
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v2 4/4] perf stat: Display metric-only for 0 counters
2025-11-12 19:53 [PATCH v2 0/4] Test fixes and debug logging Ian Rogers
` (2 preceding siblings ...)
2025-11-12 19:53 ` [PATCH v2 3/4] perf test: Don't fail if user rdpmc returns 0 when disabled Ian Rogers
@ 2025-11-12 19:53 ` Ian Rogers
2025-11-18 1:35 ` [PATCH v2 0/4] Test fixes and debug logging Namhyung Kim
4 siblings, 0 replies; 6+ messages in thread
From: Ian Rogers @ 2025-11-12 19:53 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, Kan Liang, James Clark, Chun-Tse Shao,
Thomas Falcon, Yang Li, linux-perf-users, linux-kernel
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 +++
1 file changed, 3 insertions(+)
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index 5ac9854f8c58..6d02f84c5691 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -913,6 +913,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.
--
2.51.2.1041.gc1ab5b90ca-goog
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2 0/4] Test fixes and debug logging
2025-11-12 19:53 [PATCH v2 0/4] Test fixes and debug logging Ian Rogers
` (3 preceding siblings ...)
2025-11-12 19:53 ` [PATCH v2 4/4] perf stat: Display metric-only for 0 counters Ian Rogers
@ 2025-11-18 1:35 ` Namhyung Kim
4 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2025-11-18 1:35 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
James Clark, Chun-Tse Shao, Thomas Falcon, Yang Li,
linux-perf-users, linux-kernel, Ian Rogers
On Wed, 12 Nov 2025 11:53:07 -0800, Ian Rogers wrote:
> Testing in a hypervisor guest showed some issues that these patches
> try to address, or improve the debug situation upon.
>
> v2: Rebase. Tested Arnaldo repeat case on Intel but didn't repro,
> assume was fixed as part of the legacy metric json test fixes.
>
> v1: https://lore.kernel.org/lkml/20250914182900.1960567-1-irogers@google.com/
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 6+ messages in thread