Messages in this thread Patch in this message | | | From | kan.liang@linux ... | Subject | [PATCH 3/4] perf: Check the supported CPU of an event | Date | Wed, 16 Jun 2021 11:55:33 -0700 |
| |
From: Kan Liang <kan.liang@linux.intel.com>
All architectures, which support the filter_match callback, check whether an event is schedulable on the current CPU. Since the supported_cpus is moved to struct pmu, the check can be done in the generic code. The filter_match callback can be avoided for some architecture, e.g., x86.
Signed-off-by: Kan Liang <kan.liang@linux.intel.com> --- kernel/events/core.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c index b172f54..7140f40 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -2225,9 +2225,19 @@ static bool is_orphaned_event(struct perf_event *event) return event->state == PERF_EVENT_STATE_DEAD; } +static __always_inline bool pmu_can_sched_on_this_cpu(struct pmu *pmu) +{ + return cpumask_empty(&pmu->supported_cpus) || + cpumask_test_cpu(smp_processor_id(), &pmu->supported_cpus); +} + static inline int __pmu_filter_match(struct perf_event *event) { struct pmu *pmu = event->pmu; + + if (!pmu_can_sched_on_this_cpu(pmu)) + return 0; + return pmu->filter_match ? pmu->filter_match(event) : 1; } @@ -3825,7 +3835,7 @@ static inline void perf_event_context_update_hybrid(struct perf_event_context *c { struct pmu *pmu = ctx->pmu; - if (cpumask_empty(&pmu->supported_cpus) || cpumask_test_cpu(smp_processor_id(), &pmu->supported_cpus)) + if (pmu_can_sched_on_this_cpu(pmu)) return; rcu_read_lock(); -- 2.7.4
| |