Skip to content

Commit 5967a19

Browse files
ilkka-koskinenwilldeacon
authored andcommitted
perf: arm_pmuv3: Use BR_RETIRED for HW branch event if enabled
The PMU driver attempts to use PC_WRITE_RETIRED for the HW branch event, if enabled. However, PC_WRITE_RETIRED counts only taken branches, whereas BR_RETIRED counts also non-taken ones. Furthermore, perf uses HW branch event to calculate branch misses ratio, implying BR_RETIRED is the correct event to count. We keep PC_WRITE_RETIRED still as an option in case BR_RETIRED isn't implemented. Signed-off-by: Ilkka Koskinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 91df34e commit 5967a19

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/perf/arm_pmuv3.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,14 +1086,14 @@ static int __armv8_pmuv3_map_event_id(struct arm_pmu *armpmu,
10861086
if (event->attr.type == PERF_TYPE_HARDWARE &&
10871087
event->attr.config == PERF_COUNT_HW_BRANCH_INSTRUCTIONS) {
10881088

1089-
if (test_bit(ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED,
1090-
armpmu->pmceid_bitmap))
1091-
return ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED;
1092-
10931089
if (test_bit(ARMV8_PMUV3_PERFCTR_BR_RETIRED,
10941090
armpmu->pmceid_bitmap))
10951091
return ARMV8_PMUV3_PERFCTR_BR_RETIRED;
10961092

1093+
if (test_bit(ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED,
1094+
armpmu->pmceid_bitmap))
1095+
return ARMV8_PMUV3_PERFCTR_PC_WRITE_RETIRED;
1096+
10971097
return HW_OP_UNSUPPORTED;
10981098
}
10991099

0 commit comments

Comments
 (0)