Skip to contentSkip to conversation

Test fixes and debug logging

PATCH Applied Ian Rogers 2 participants 6 messages Nov 12, 2025 – Nov 18, 2025 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

v2 cover Test fixes and debug logging

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/[email protected]/

Ian Rogers (4):
perf test: Be tolerant of missing json metric none value perf parse-events: Add debug logging to perf_event perf test: Don't fail if user rdpmc returns 0 when disabled perf stat: Display metric-only for 0 counters

 tools/perf/tests/mmap-basic.c                       | 2 +-
 tools/perf/tests/shell/lib/perf_json_output_lint.py | 5 ++++-
 tools/perf/util/parse-events.c                      | 2 ++
 tools/perf/util/stat-display.c                      | 3 +++
 4 files changed, 10 insertions(+), 2 deletions(-)
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
author reviewer
#1 lore raw

PATCH v2 1/4 perf test: Be tolerant of missing json metric none value

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.

---
 tools/perf/tests/shell/lib/perf_json_output_lint.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/tests/shell/lib/perf_json_output_lint.py +4 -1
index 1369baaa0361..dafbde56cc76 100644
@@ -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,
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
author reviewer
#2 lore raw

PATCH v2 2/4 perf parse-events: Add debug logging to perf_event

In reply to Ian Rogers

If verbose is enabled and parse_event is called, typically by tests, log failures.

---
 tools/perf/util/parse-events.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/parse-events.c +2 -0
index 0c0dc20b1c13..e522082c5a21 100644
@@ -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;
 }
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
author reviewer
#3 lore raw

PATCH v2 3/4 perf test: Don't fail if user rdpmc returns 0 when disabled

In reply to Ian Rogers

In certain hypervisor set ups the value 0 may be returned but this is only erroneous if the user rdpmc isn't disabled.

---
 tools/perf/tests/mmap-basic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/mmap-basic.c +1 -1
index 3c89d3001887..3313c236104e 100644
@@ -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;
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
author reviewer
#4 lore raw

PATCH v2 4/4 perf stat: Display metric-only for 0 counters

In reply to Ian Rogers

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.

---
 tools/perf/util/stat-display.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/util/stat-display.c +3 -0
index 5ac9854f8c58..6d02f84c5691 100644
@@ -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.
Signature · 1 line
2.51.2.1041.gc1ab5b90ca-goog
maintainer Applied
#5 lore raw
In reply to Ian Rogers
Quoted 9 lines · Ian Rogers

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/[email protected]/

[...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung