This is a note to let you know that I've just added the patch titled perf metric: Fix metric_leader to the 5.16-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: perf-metric-fix-metric_leader.patch and it can be found in the queue-5.16 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From d3e2bb4359f70c8b1d09a6f8e2f57240aab0da3f Mon Sep 17 00:00:00 2001 From: Ian Rogers <irogers@xxxxxxxxxx> Date: Fri, 14 Jan 2022 22:28:52 -0800 Subject: perf metric: Fix metric_leader From: Ian Rogers <irogers@xxxxxxxxxx> commit d3e2bb4359f70c8b1d09a6f8e2f57240aab0da3f upstream. Multiple events may have a metric_leader to aggregate into. This happens for uncore events where, for example, uncore_imc is expanded into uncore_imc_0, uncore_imc_1, etc. Such events all have the same metric_id and should aggregate into the first event. The change introducing metric_ids had a bug where the metric_id was compared to itself, creating an always true condition. Correct this by comparing the event in the metric_evlist and the metric_leader. Fixes: ec5c5b3d2c21b3f3 ("perf metric: Encode and use metric-id as qualifier") Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx> Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx> Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx> Cc: Jiri Olsa <jolsa@xxxxxxxxxx> Cc: John Garry <john.garry@xxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: Namhyung Kim <namhyung@xxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Cc: Stephane Eranian <eranian@xxxxxxxxxx> Link: http://lore.kernel.org/lkml/20220115062852.1959424-1-irogers@xxxxxxxxxx Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- tools/perf/util/metricgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -314,7 +314,7 @@ static int setup_metric_events(struct ha */ metric_id = evsel__metric_id(ev); evlist__for_each_entry_continue(metric_evlist, ev) { - if (!strcmp(evsel__metric_id(metric_events[i]), metric_id)) + if (!strcmp(evsel__metric_id(ev), metric_id)) ev->metric_leader = metric_events[i]; } } Patches currently in stable-queue which might be from irogers@xxxxxxxxxx are queue-5.16/perf-metricgroup-fix-use-after-free-in-metric__new.patch queue-5.16/perf-cputopo-fix-cpu-topology-reading-on-s-390.patch queue-5.16/perf-evsel-override-attr-sample_period-for-non-libpfm4-events.patch queue-5.16/perf-test-enable-system-wide-for-metricgroups-test.patch queue-5.16/perf-metric-fix-metric_leader.patch