perf stat: Fix the hard-coded metrics calculation on the hybrid
Subsystems (2)
PATCH v2 1/1 perf stat: Fix the hard-coded metrics calculation on the hybrid
From: Kan Liang <[email protected]>
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 cycleThe 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.
---
Changes since V1:
- Don't check the PMU of the SW CLOCK events
tools/perf/util/stat-shadow.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/perf/util/stat-shadow.c +7 -0
@@ -176,6 +176,13 @@ static double find_stat(const struct evsel *evsel, int aggr_idx, enum stat_typeif (type !=evsel__stat_type (cur))continue ; +/* +* Except the SW CLOCK events, +* ignore if not the PMU we're looking for. +*/ +if ((type !=STAT_NSECS ) && (evsel->pmu != cur->pmu)) +continue ; + aggr = &cur->stats->aggr[aggr_idx];if (type ==STAT_NSECS )return aggr->counts.val;
Signature · 1 line
2.35.1
Quoted 23 lines · On Thu, Jun 06, 2024 at 11:03:16AM -0700, [email protected] wrote:
From: Kan Liang <[email protected]>
The hard-coded metrics is wrongly calculated on the hybrid machine.
$ perf stat -e cycles,instructions -a sleep 1Performance 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 cycleThe insn per cycle for
cpu_coreshould 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 thecpu_core.In the hard-coded metrics, the events from a different PMU are only
SW_CPU_CLOCKandSW_TASK_CLOCK. They both have the stat type,STAT_NSECS. Except the SW CLOCK events, check the PMU type as well.
Quoted 5 lines
Fixes 0a57b910807a ("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]>
Thanks,
Namhyung
Quoted 29 lines
---
Changes since V1:
- Don't check the PMU of the SW CLOCK eventstools/perf/util/stat-shadow.c | 7 +++++++ 1 file changed, 7 insertions(+)tools/perf/util/stat-shadow.c +7
-0@@ -176,6 +176,13 @@ static double find_stat(const struct evsel *evsel, int aggr_idx, enum stat_typeif (type !=evsel__stat_type (cur))continue ; +/* +* Except the SW CLOCK events, +* ignore if not the PMU we're looking for. +*/ +if ((type !=STAT_NSECS ) && (evsel->pmu != cur->pmu)) +continue ; + aggr = &cur->stats->aggr[aggr_idx];if (type ==STAT_NSECS )return aggr->counts.val;Signature · 1 line
2.35.1
Quoted 4 lines · On Thu, 06 Jun 2024 11:03:16 -0700, [email protected] wrote:
The hard-coded metrics is wrongly calculated on the hybrid machine.
$ perf stat -e cycles,instructions -a sleep 1
Quoted 8 lines
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[...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung