Skip to content

Commit f09d5a0

Browse files
bwicaksononvnvmochs
authored andcommitted
NVIDIA: VR: SAUCE: perf/arm_pmu: Skip PMCCNTR_EL0 on NVIDIA Olympus
The PMCCNTR_EL0 in NVIDIA Olympus CPU may increment while in WFI/WFE, which does not align with counting CPU_CYCLES on a programmable counter. Add a MIDR range entry and refuse PMCCNTR_EL0 for cycle events on affected parts so perf does not mix the two behaviors. Signed-off-by: Besar Wicaksono <bwicaksono@nvidia.com> (backported from https://lore.kernel.org/all/20260406232034.2566133-1-bwicaksono@nvidia.com/) Signed-off-by: Matthew R. Ochs <mochs@nvidia.com>
1 parent 5e154c9 commit f09d5a0

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

drivers/perf/arm_pmuv3.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,29 @@ static int armv8pmu_get_chain_idx(struct pmu_hw_events *cpuc,
978978
return -EAGAIN;
979979
}
980980

981+
/*
982+
* List of CPUs that should avoid using PMCCNTR_EL0.
983+
*/
984+
static struct midr_range armv8pmu_avoid_pmccntr_cpus[] = {
985+
/*
986+
* The PMCCNTR_EL0 in Olympus CPU may still increment while in WFI/WFE state.
987+
* This is an implementation specific behavior and not an erratum.
988+
*
989+
* From ARM DDI0487 D14.4:
990+
* It is IMPLEMENTATION SPECIFIC whether CPU_CYCLES and PMCCNTR count
991+
* when the PE is in WFI or WFE state, even if the clocks are not stopped.
992+
*
993+
* From ARM DDI0487 D24.5.2:
994+
* All counters are subject to any changes in clock frequency, including
995+
* clock stopping caused by the WFI and WFE instructions.
996+
* This means that it is CONSTRAINED UNPREDICTABLE whether or not
997+
* PMCCNTR_EL0 continues to increment when clocks are stopped by WFI and
998+
* WFE instructions.
999+
*/
1000+
MIDR_ALL_VERSIONS(MIDR_NVIDIA_OLYMPUS),
1001+
{}
1002+
};
1003+
9811004
static bool armv8pmu_can_use_pmccntr(struct pmu_hw_events *cpuc,
9821005
struct perf_event *event)
9831006
{
@@ -1011,6 +1034,14 @@ static bool armv8pmu_can_use_pmccntr(struct pmu_hw_events *cpuc,
10111034
if (cpu_pmu->has_smt)
10121035
return false;
10131036

1037+
/*
1038+
* On some CPUs, PMCCNTR_EL0 does not match the behavior of CPU_CYCLES
1039+
* programmable counter, so avoid routing cycles through PMCCNTR_EL0 to
1040+
* prevent inconsistency in the results.
1041+
*/
1042+
if (is_midr_in_range_list(armv8pmu_avoid_pmccntr_cpus))
1043+
return false;
1044+
10141045
return true;
10151046
}
10161047

0 commit comments

Comments
 (0)