Skip to content

Commit 37f322c

Browse files
captain5050acmel
authored andcommitted
perf stat: Avoid merging/aggregating metric counts twice
The added perf_stat_merge_counters combines uncore counters. When metrics are enabled, the counts are merged into a metric_leader via the stat-shadow saved_value logic. As the leader now is passed an aggregated count, it leads to all counters being added together twice and counts appearing approximately doubled in metrics. This change disables the saved_value merging of counts for evsels that are merged. It is recommended that later changes remove the saved_value entirely as the two layers of aggregation in the code is confusing. Fixes: 942c559 ("perf stat: Add perf_stat_merge_counters()") Reported-by: Perry Taylor <[email protected]> Signed-off-by: Ian Rogers <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Eduard Zingerman <[email protected]> Cc: Florian Fischer <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Xing Zhengjun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 6a5558f commit 37f322c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/util/stat-shadow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ void perf_stat__update_shadow_stats(struct evsel *counter, u64 count,
311311
update_stats(&v->stats, count);
312312
if (counter->metric_leader)
313313
v->metric_total += count;
314-
} else if (counter->metric_leader) {
314+
} else if (counter->metric_leader && !counter->merged_stat) {
315315
v = saved_value_lookup(counter->metric_leader,
316316
map_idx, true, STAT_NONE, 0, st, rsd.cgrp);
317317
v->metric_total += count;

0 commit comments

Comments
 (0)