[PATCH v3 00/14] perf stat: Decouple printing API and introduce streaming zero-allocation printers
From: Ian Rogers
Date: Thu Jul 16 2026 - 00:33:02 EST
This is V3 of the patch series implementing the decoupled perf stat printing
architecture. This series fully separates the format-specific display engines
(STD, CSV, JSON) into distinct isolated files, and guarantees 100% streaming,
zero-allocation output for interval metric-only JSON data to avoid debug
artifact overwrites and large allocations on extended system-wide runs.
Changes since v2:
- Fixed trailing newline count and padding logic for wide metric names
in standard console (STD) metric-only interval modes, resolving reports
from Sashiko AI.
- Resolved aggr header label misalignments for Socket/Die/Node/Cache modes.
- Addressed debug artifact overwrite bugs in the `stat_metrics_values.sh`
rules validation engine by correctly scoping execution passes and preserving
artifacts upon failure.
- Reverted all reflow diff noise in `builtin-stat.c` and legacy metric print
functions in `util/stat-display.c` per feedback from Arnaldo.
- Converted all format callback file creations to use standard `//` SPDX header
formatting directly in the patch series to prevent downstream diff noise.
- Resolved all internal brace styles, variable declaration spacing, and unwrapped
commit description warnings reported by checkpatch.pl.
- Added all requested Acked-by tags from reviewers.
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 | 6 +-
tools/perf/util/stat-print-csv.c | 534 +++++++++++
tools/perf/util/stat-print-json.c | 330 +++++++
tools/perf/util/stat-print-std.c | 828 ++++++++++++++++++
tools/perf/util/stat-print.c | 489 +++++++++++
tools/perf/util/stat-print.h | 133 +++
tools/perf/util/stat.h | 2 +
14 files changed, 2488 insertions(+), 79 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