Skip to content

Commit 3612ca8

Browse files
Kan Liangnamhyung
authored andcommitted
perf stat: Fix the hard-coded metrics calculation on the hybrid
The hard-coded metrics is wrongly calculated on the hybrid machine. $ perf stat -e cycles,instructions -a sleep 1 Performance counter stats for 'system wide': 18,205,487 cpu_atom/cycles/ 9,733,603 cpu_core/cycles/ 9,423,111 cpu_atom/instructions/ # 0.52 insn per cycle 4,268,965 cpu_core/instructions/ # 0.23 insn per cycle The insn per cycle for cpu_core should be 4,268,965 / 9,733,603 = 0.44. When finding the metric events, the find_stat() doesn't take the PMU type into account. The cpu_atom/cycles/ is wrongly used to calculate the IPC of the cpu_core. In the hard-coded metrics, the events from a different PMU are only SW_CPU_CLOCK and SW_TASK_CLOCK. They both have the stat type, STAT_NSECS. Except the SW CLOCK events, check the PMU type as well. Fixes: 0a57b91 ("perf stat: Use counts rather than saved_value") Reported-by: Khalil, Amiri <[email protected]> Reviewed-by: Ian Rogers <[email protected]> Signed-off-by: Kan Liang <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: [email protected] Signed-off-by: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 788c516 commit 3612ca8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/perf/util/stat-shadow.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ static double find_stat(const struct evsel *evsel, int aggr_idx, enum stat_type
176176
if (type != evsel__stat_type(cur))
177177
continue;
178178

179+
/*
180+
* Except the SW CLOCK events,
181+
* ignore if not the PMU we're looking for.
182+
*/
183+
if ((type != STAT_NSECS) && (evsel->pmu != cur->pmu))
184+
continue;
185+
179186
aggr = &cur->stats->aggr[aggr_idx];
180187
if (type == STAT_NSECS)
181188
return aggr->counts.val;

0 commit comments

Comments
 (0)