[PATCH v4 00/14] perf stat: Decouple and modularize display formatting

From: Ian Rogers

Date: Thu Jul 16 2026 - 03:06:18 EST


This patch set decouples and modularizes `perf stat` metric and event
counter display processing into a unified traversal engine supporting
pluggable, format-specific callbacks for standard (STD), CSV, and JSON
outputs via the new `--new` flag.

Changes in v4:
- Squash all multi-metric column padding, zero-skip logic, and formatting
fixes directly into their introducing commits for a perfectly bisectable,
pristine Git history.
- Avoid newlines before signed-off-by, assisted-by, and acked-by tags,
organizing all contributor tags into a single, contiguous block for strict
checkpatch and LKML compliance.
- Introduce strict, grid-based column padding to perfectly align multi-metric
events (e.g. TopdownL1) across both standard and metric-only CSV rows, guaranteeing
perfect 6-comma and 7-comma parsing compliance by external DataFrame engines.
- Refactor the PMU and hybrid metric event printer to propagate identical zero-counter
skipping semantics in alignment with the legacy abs_printout path.
- Re-run all STD, JSON, and CSV linter test suites to achieve 100% passing status.

Ian Rogers (14):
perf stat: Introduce core generic print traversal engine and header
stubs
perf stat: Implement standard console (STD) formatting callbacks
perf stat: Extend STD output linter to test basic New API checks
perf stat: Extend STD output linter to test core aggregation checks
perf stat: Extend STD output linter to test advanced PMU checks
perf stat: Extend STD output linter to test metric-only checks
perf stat: Implement CSV formatting callbacks
perf stat: Extend CSV output linter to test core aggregation checks
perf stat: Extend CSV output linter to test advanced PMU and
metric-only checks
perf stat: Implement streaming JSON formatting callbacks
perf stat: Extend JSON output linter to test core aggregation checks
perf stat: Extend JSON output linter to test advanced PMU and
metric-only checks
perf stat: Add --new support to PMU metrics Python validator
perf stat: Extend PMU metrics value linter to validate --new outputs

tools/perf/builtin-stat.c | 96 +-
.../tests/shell/lib/perf_metric_validation.py | 12 +-
tools/perf/tests/shell/stat+csv_output.sh | 19 +
tools/perf/tests/shell/stat+json_output.sh | 74 +-
tools/perf/tests/shell/stat+std_output.sh | 18 +
tools/perf/tests/shell/stat_metrics_values.sh | 22 +-
tools/perf/util/Build | 4 +
tools/perf/util/stat-display.c | 12 +-
tools/perf/util/stat-print-csv.c | 677 ++++++++++++++
tools/perf/util/stat-print-json.c | 339 +++++++
tools/perf/util/stat-print-std.c | 854 ++++++++++++++++++
tools/perf/util/stat-print.c | 500 ++++++++++
tools/perf/util/stat-print.h | 137 +++
tools/perf/util/stat.h | 6 +
14 files changed, 2688 insertions(+), 82 deletions(-)
create mode 100644 tools/perf/util/stat-print-csv.c
create mode 100644 tools/perf/util/stat-print-json.c
create mode 100644 tools/perf/util/stat-print-std.c
create mode 100644 tools/perf/util/stat-print.c
create mode 100644 tools/perf/util/stat-print.h

--
2.55.0.141.g00534a21ce-goog