Skip to content

Commit 3e830f6

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86: Optimize the is_x86_event
The current is_x86_event has to go through the hybrid_pmus list to find the matched pmu, then check if it's a X86 PMU and a X86 event. It's not necessary. The X86 PMU has a unique type ID on a non-hybrid machine, and a unique capability type. They are good enough to do the check. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent efd4485 commit 3e830f6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

arch/x86/events/core.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -762,15 +762,16 @@ void x86_pmu_enable_all(int added)
762762

763763
int is_x86_event(struct perf_event *event)
764764
{
765-
int i;
766-
767-
if (!is_hybrid())
768-
return event->pmu == &pmu;
769-
770-
for (i = 0; i < x86_pmu.num_hybrid_pmus; i++) {
771-
if (event->pmu == &x86_pmu.hybrid_pmu[i].pmu)
772-
return true;
773-
}
765+
/*
766+
* For a non-hybrid platforms, the type of X86 pmu is
767+
* always PERF_TYPE_RAW.
768+
* For a hybrid platform, the PERF_PMU_CAP_EXTENDED_HW_TYPE
769+
* is a unique capability for the X86 PMU.
770+
* Use them to detect a X86 event.
771+
*/
772+
if (event->pmu->type == PERF_TYPE_RAW ||
773+
event->pmu->capabilities & PERF_PMU_CAP_EXTENDED_HW_TYPE)
774+
return true;
774775

775776
return false;
776777
}

0 commit comments

Comments
 (0)