Skip to content

Commit 2fe6575

Browse files
sandip4nacmel
authored andcommitted
perf script: Skip aggregation for stat events
The script command does not support aggregation modes by itself although that can be achieved using post-processing scripts. Because of this, it does not allocate memory for aggregated event values. Upon running perf stat record, the aggregation mode is set in the perf data file. If the mode is AGGR_GLOBAL, the aggregated event values are accessed and this leads to a segmentation fault since these were never allocated to begin with. Set the mode to AGGR_NONE explicitly to avoid this. E.g. $ perf stat record -e cycles true $ perf script Before: Segmentation fault (core dumped) After: CPU THREAD VAL ENA RUN TIME EVENT -1 231919 162831 362069 362069 935289 cycles:u Fixes: 8b76a31 ("perf stat: Remove unused perf_counts.aggr field") Signed-off-by: Sandipan Das <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ananth Narayan <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Nick Terrell <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: [email protected] # v6.2+ Link: https://lore.kernel.org/r/83d6c6c05c54bf00c5a9df32ac160718efca0c7a.1683280603.git.sandipan.das@amd.com Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a2af0f6 commit 2fe6575

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/perf/builtin-script.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3647,6 +3647,13 @@ static int process_stat_config_event(struct perf_session *session __maybe_unused
36473647
union perf_event *event)
36483648
{
36493649
perf_event__read_stat_config(&stat_config, &event->stat_config);
3650+
3651+
/*
3652+
* Aggregation modes are not used since post-processing scripts are
3653+
* supposed to take care of such requirements
3654+
*/
3655+
stat_config.aggr_mode = AGGR_NONE;
3656+
36503657
return 0;
36513658
}
36523659

0 commit comments

Comments
 (0)