Re: [PATCH V2] arm64: perf: Retain PMCR.X of PMCR_EL0 during reset

From: Will Deacon
Date: Fri May 06 2022 - 10:12:26 EST


On Fri, Apr 29, 2022 at 04:59:09PM +0530, Srinivasarao Pathipati wrote:
> Preserve the bit PMCR.X of PMCR_EL0 during PMU reset to export
> PMU events. as it could be set before PMU initialization.
>
> Signed-off-by: Srinivasarao Pathipati <quic_c_spathi@xxxxxxxxxxx>
> ---
> Changes since V1:
> - Preserving only PMCR_X bit as per Robin Murphy's comment
> ---
> arch/arm64/kernel/perf_event.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
> index cb69ff1..532a417 100644
> --- a/arch/arm64/kernel/perf_event.c
> +++ b/arch/arm64/kernel/perf_event.c
> @@ -1047,6 +1047,9 @@ static void armv8pmu_reset(void *info)
> if (armv8pmu_has_long_event(cpu_pmu))
> pmcr |= ARMV8_PMU_PMCR_LP;
>
> + /* Preserve PMCR_X to export PMU events */
> + pmcr |= (armv8pmu_pmcr_read() & ARMV8_PMU_PMCR_X);

I don't think this should be unconditional. Exporting events could easily
result in additional power consumption, and potentially even hardware
lockups.

Please stick this behind something like a sysctl toggle or sysfs control,
with documentation about what it does. It should default to disabled.

Will