From: Ian Rogers Date: Mon, 22 Aug 2022 21:33:51 +0000 (-0700) Subject: perf stat: Clear evsel->reset_group for each stat run X-Git-Tag: v5.15.73~638 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da86f80da31a1f8289b3d0bbb98050a6a7b68d20;p=platform%2Fkernel%2Flinux-rpi.git perf stat: Clear evsel->reset_group for each stat run commit bf515f024e4c0ca46a1b08c4f31860c01781d8a5 upstream. If a weak group is broken then the reset_group flag remains set for the next run. Having reset_group set means the counter isn't created and ultimately a segfault. A simple reproduction of this is: # perf stat -r2 -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}:W which will be added as a test in the next patch. Fixes: 4804e0111662d7d8 ("perf stat: Use affinity for opening events") Reviewed-by: Andi Kleen Signed-off-by: Ian Rogers Tested-by: Arnaldo Carvalho de Melo Tested-by: Xing Zhengjun Cc: Alexander Shishkin Cc: Andi Kleen Cc: Ingo Molnar Cc: Jiri Olsa Cc: Kan Liang Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: https://lore.kernel.org/r/20220822213352.75721-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Greg Kroah-Hartman --- diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 1a194edb5452..abf88a1ad455 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -807,6 +807,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) return -1; evlist__for_each_entry(evsel_list, counter) { + counter->reset_group = false; if (bpf_counter__load(counter, &target)) return -1; if (!evsel__is_bpf(counter))