[Patch v2 1/2] perf/x86: Introduce is_x86_pmu() helper
From: Dapeng Mi
Date: Mon Mar 16 2026 - 01:12:59 EST
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.
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
Signed-off-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx>
---
v2: new patch.
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 810ab21ffd99..66b1a873c395 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 fad87d3c8b2c..025f67726ecc 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)
{
base-commit: becb26c89be3a6448dcd92522894427544d5b091
--
2.34.1