[PATCH v2 1/7] perf stat: Release aggregation maps on report exit
From: Leo Yan
Date: Fri Dec 04 2026 - 06:23:55 EST
Report mode bypasses the aggregation cleanup in cmd_stat(). An event
processing error also returns from __cmd_report() before session
deletion.
Run perf_stat__exit_aggr_mode() and perf_session__delete() on both
success and error, and return the event processing status.
Fixes: 68d702f7a120 ("perf stat report: Add support to initialize aggr_map from file")
Link: https://sashiko.dev/#/bug/linux-b77574e3-cc57-4338-8810-73a0cfa6fff7
Signed-off-by: Leo Yan <leo.yan@xxxxxxx>
---
tools/perf/builtin-stat.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 2647878b8711427e33d21bdf66c37ffa854e2b9d..1d440d66cc3eb76c3a461445042fed3d65d8d570 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -2418,11 +2418,10 @@ static int __cmd_report(int argc, const char **argv)
evsel_list = session->evlist;
ret = perf_session__process_events(session);
- if (ret)
- return ret;
+ perf_stat__exit_aggr_mode();
perf_session__delete(session);
- return 0;
+ return ret;
}
static void setup_system_wide(int forks)
--
2.34.1