[RFC PATCH v7 04/28] perf: arm_spe_pmu: Move struct arm_spe_pmu to a separate header file

Lorenzo Stoakes (ARM) ljs at kernel.org
Thu Oct 15 07:40:09 PDT 2026


On Thu, Sep 03, 2026 at 05:05:59PM +0100, Alexandru Elisei wrote:
> KVM will soon want to make use of struct arm_spe_pmu, move it to a separate
> header where it will be easily accessible.
>
> Cc: Will Deacon <will at kernel.org>
> Signed-off-by: Alexandru Elisei <alexandru.elisei at arm.com>

Looks to be a straightforward mechanical change, couple nits below but with
those addressed:

Reviewed-by: Lorenzo Stoakes (ARM) <ljs at kernel.org>

> ---
>  drivers/perf/arm_spe_pmu.c       | 33 +--------------------
>  include/linux/perf/arm_spe_pmu.h | 50 ++++++++++++++++++++++++++++++++

This should be added to MAINTAINERS too I think?

>  2 files changed, 51 insertions(+), 32 deletions(-)
>  create mode 100644 include/linux/perf/arm_spe_pmu.h
>
> diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c
> index b70f3fedf028..79c571a649d5 100644
> --- a/drivers/perf/arm_spe_pmu.c
> +++ b/drivers/perf/arm_spe_pmu.c
> @@ -28,6 +28,7 @@
>  #include <linux/of.h>
>  #include <linux/perf_event.h>
>  #include <linux/perf/arm_pmu.h>
> +#include <linux/perf/arm_spe_pmu.h>
>  #include <linux/platform_device.h>
>  #include <linux/printk.h>
>  #include <linux/slab.h>
> @@ -67,38 +68,6 @@ struct arm_spe_pmu_buf {
>  	void					*base;
>  };
>
> -struct arm_spe_pmu {
> -	struct pmu				pmu;
> -	struct platform_device			*pdev;
> -	cpumask_t				supported_cpus;
> -	struct hlist_node			hotplug_node;
> -
> -	int					irq; /* PPI */
> -	u16					pmsver;
> -	u16					min_period;
> -	u16					counter_sz;
> -
> -#define SPE_PMU_FEAT_FILT_EVT			(1UL << 0)
> -#define SPE_PMU_FEAT_FILT_TYP			(1UL << 1)
> -#define SPE_PMU_FEAT_FILT_LAT			(1UL << 2)
> -#define SPE_PMU_FEAT_ARCH_INST			(1UL << 3)
> -#define SPE_PMU_FEAT_LDS			(1UL << 4)
> -#define SPE_PMU_FEAT_ERND			(1UL << 5)
> -#define SPE_PMU_FEAT_INV_FILT_EVT		(1UL << 6)
> -#define SPE_PMU_FEAT_DISCARD			(1UL << 7)
> -#define SPE_PMU_FEAT_EFT			(1UL << 8)
> -#define SPE_PMU_FEAT_FDS			(1UL << 9)
> -#define SPE_PMU_FEAT_DEV_PROBED			(1UL << 63)
> -	u64					features;
> -
> -	u64					pmsevfr_res0;
> -	u16					max_record_sz;
> -	u16					align;
> -	struct perf_output_handle __percpu	*handle;
> -};
> -
> -#define to_spe_pmu(p) (container_of(p, struct arm_spe_pmu, pmu))
> -
>  /* Convert a free-running index from perf into an SPE buffer offset */
>  #define PERF_IDX2OFF(idx, buf) \
>  	((idx) % ((unsigned long)(buf)->nr_pages << PAGE_SHIFT))
> diff --git a/include/linux/perf/arm_spe_pmu.h b/include/linux/perf/arm_spe_pmu.h
> new file mode 100644
> index 000000000000..af86fd184050
> --- /dev/null
> +++ b/include/linux/perf/arm_spe_pmu.h
> @@ -0,0 +1,50 @@
> +// SPDX-License-Identifier: GPL-2.0

Pedantic I know, sorry :P but as per Documentation/process/license-rules.rst:

      C source:	// SPDX-License-Identifier: <SPDX License Expression>
      C header:	/* SPDX-License-Identifier: <SPDX License Expression> */
      ...

So should be /* */ here.

> +/*
> + * Split from driver/perf/arm_spe_pmu.c

NIT: should be drivers/...

> + *
> + * Copyright (C) 2016 ARM Limited
> + */
> +
> +#ifndef __PERF_ARM_SPE_PMU_H__
> +#define __PERF_ARM_SPE_PMU_H__
> +
> +#include <linux/cpumask.h>
> +#include <linux/container_of.h>
> +#include <linux/list.h>
> +#include <linux/perf_event.h>
> +#include <linux/platform_device.h>
> +#include <linux/types.h>
> +
> +struct arm_spe_pmu {
> +	struct pmu				pmu;
> +	struct platform_device			*pdev;
> +	cpumask_t				supported_cpus;
> +	struct hlist_node			hotplug_node;
> +
> +	int					irq; /* PPI */
> +	u16					pmsver;
> +	u16					min_period;
> +	u16					counter_sz;
> +
> +#define SPE_PMU_FEAT_FILT_EVT			(1UL << 0)
> +#define SPE_PMU_FEAT_FILT_TYP			(1UL << 1)
> +#define SPE_PMU_FEAT_FILT_LAT			(1UL << 2)
> +#define SPE_PMU_FEAT_ARCH_INST			(1UL << 3)
> +#define SPE_PMU_FEAT_LDS			(1UL << 4)
> +#define SPE_PMU_FEAT_ERND			(1UL << 5)
> +#define SPE_PMU_FEAT_INV_FILT_EVT		(1UL << 6)
> +#define SPE_PMU_FEAT_DISCARD			(1UL << 7)
> +#define SPE_PMU_FEAT_EFT			(1UL << 8)
> +#define SPE_PMU_FEAT_FDS			(1UL << 9)
> +#define SPE_PMU_FEAT_DEV_PROBED			(1UL << 63)
> +	u64					features;
> +
> +	u64					pmsevfr_res0;
> +	u16					max_record_sz;
> +	u16					align;
> +	struct perf_output_handle __percpu	*handle;
> +};
> +
> +#define to_spe_pmu(p) (container_of(p, struct arm_spe_pmu, pmu))
> +
> +#endif /* __PERF_ARM_SPE_PMU_H__ */
> --
> 2.43.0
>
>

--
Cheers, Lorenzo



More information about the linux-arm-kernel mailing list