Re: [PATCH 2/8] perf/x86: Introduce is_x86_pmu() helper
From: Falcon, Thomas
Date: Fri Jun 05 2026 - 13:13:20 EST
On Fri, 2026-06-05 at 09:11 +0800, Dapeng Mi wrote:
> From: Ian Rogers <irogers@xxxxxxxxxx>
>
> To facilitate the detection of x86 PMU structures in upcoming
> patches,
> the is_x86_pmu() helper is introduced. Additionally, the
> is_x86_event()
> helper has been refactored to utilize is_x86_pmu().
>
> No function changes intended.
Reviewed-by: Thomas Falcon <thomas.falcon@xxxxxxxxx>
Thanks,
Tom
>
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> Signed-off-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>
> Reviewed-by: Zide Chen <zide.chen@xxxxxxxxx>
> ---
>
> Original patch link:
> https://lore.kernel.org/all/20260316050838.3624051-1-dapeng1.mi@xxxxxxxxxxxxxxx/
>
> arch/x86/events/core.c | 16 ----------------
> arch/x86/events/perf_event.h | 18 +++++++++++++++++-
> 2 files changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
> index 4b9e105309c6..3bd0522afe6d 100644
> --- a/arch/x86/events/core.c
> +++ b/arch/x86/events/core.c
> @@ -774,22 +774,6 @@ void x86_pmu_enable_all(int added)
> }
> }
>
> -int is_x86_event(struct perf_event *event)
> -{
> - /*
> - * For a non-hybrid platforms, the type of X86 pmu is
> - * always PERF_TYPE_RAW.
> - * For a hybrid platform, the PERF_PMU_CAP_EXTENDED_HW_TYPE
> - * is a unique capability for the X86 PMU.
> - * Use them to detect a X86 event.
> - */
> - if (event->pmu->type == PERF_TYPE_RAW ||
> - event->pmu->capabilities &
> PERF_PMU_CAP_EXTENDED_HW_TYPE)
> - return true;
> -
> - return false;
> -}
> -
> struct pmu *x86_get_pmu(unsigned int cpu)
> {
> struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
> diff --git a/arch/x86/events/perf_event.h
> b/arch/x86/events/perf_event.h
> index 5902a297daa1..dbb5c8e8a8ea 100644
> --- a/arch/x86/events/perf_event.h
> +++ b/arch/x86/events/perf_event.h
> @@ -115,7 +115,23 @@ static inline bool is_topdown_event(struct
> perf_event *event)
> return is_metric_event(event) || is_slots_event(event);
> }
>
> -int is_x86_event(struct perf_event *event);
> +static inline bool is_x86_pmu(struct pmu *pmu)
> +{
> + /*
> + * For a non-hybrid platforms, the type of X86 pmu is
> + * always PERF_TYPE_RAW.
> + * For a hybrid platform, the PERF_PMU_CAP_EXTENDED_HW_TYPE
> + * is a unique capability for the X86 PMU.
> + * Use them to detect a X86 event.
> + */
> + return pmu->type == PERF_TYPE_RAW ||
> + pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE;
> +}
> +
> +static inline bool is_x86_event(struct perf_event *event)
> +{
> + return is_x86_pmu(event->pmu);
> +}
>
> static inline bool check_leader_group(struct perf_event *leader, int
> flags)
> {