[PATCH 7/9] arm64: perf/kvm: Use a common PMU cycle counter define

Mark Rutland mark.rutland at arm.com
Mon Jun 10 04:24:39 PDT 2024


On Fri, Jun 07, 2024 at 02:31:32PM -0600, Rob Herring (Arm) wrote:
> The PMUv3 and KVM code each have a define for the PMU cycle counter
> index. Move KVM's define to a shared location and use it for PMUv3
> driver.
> 
> Signed-off-by: Rob Herring (Arm) <robh at kernel.org>
> ---
>  arch/arm/include/asm/arm_pmuv3.h   |  2 ++
>  arch/arm64/include/asm/arm_pmuv3.h |  2 ++
>  arch/arm64/kvm/sys_regs.c          |  1 +
>  drivers/perf/arm_pmuv3.c           | 23 +++++++++--------------
>  include/kvm/arm_pmu.h              |  1 -
>  5 files changed, 14 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arm_pmuv3.h b/arch/arm/include/asm/arm_pmuv3.h
> index a41b503b7dcd..ac2cf37b57e3 100644
> --- a/arch/arm/include/asm/arm_pmuv3.h
> +++ b/arch/arm/include/asm/arm_pmuv3.h
> @@ -9,6 +9,8 @@
>  #include <asm/cp15.h>
>  #include <asm/cputype.h>
>  
> +#define ARMV8_PMU_CYCLE_IDX		31
> +
>  #define PMCCNTR			__ACCESS_CP15_64(0, c9)
>  
>  #define PMCR			__ACCESS_CP15(c9,  0, c12, 0)
> diff --git a/arch/arm64/include/asm/arm_pmuv3.h b/arch/arm64/include/asm/arm_pmuv3.h
> index 1ed91334fede..46930729fb3f 100644
> --- a/arch/arm64/include/asm/arm_pmuv3.h
> +++ b/arch/arm64/include/asm/arm_pmuv3.h
> @@ -11,6 +11,8 @@
>  #include <asm/cpufeature.h>
>  #include <asm/sysreg.h>
>  
> +#define ARMV8_PMU_CYCLE_IDX		31

I think we can define this in <linux/perf/arm_pmuv3.h>, rather than
needing separate definitions for arm/arm64. 

> diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
> index f8b5db48ea8a..22393ae7ce14 100644
> --- a/arch/arm64/kvm/sys_regs.c
> +++ b/arch/arm64/kvm/sys_regs.c
> @@ -18,6 +18,7 @@
>  #include <linux/printk.h>
>  #include <linux/uaccess.h>
>  
> +#include <asm/arm_pmuv3.h>
>  #include <asm/cacheflush.h>
>  #include <asm/cputype.h>
>  #include <asm/debug-monitors.h>

... so we'd need to change the include here, but the rest of this patch
looks good as-is.

Mark.



More information about the linux-arm-kernel mailing list