[PATCH v5 09/10] perf: optimize event_filter_match during sched_in

From: Ian Rogers
Date: Fri Dec 06 2019 - 18:16:16 EST


The caller verified the CPU and cgroup so directly call
pmu_filter_match.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
kernel/events/core.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 5935d2474050..bcaf100d8167 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2227,8 +2227,11 @@ static inline int pmu_filter_match(struct perf_event *event)
static inline int
event_filter_match(struct perf_event *event)
{
- return (event->cpu == -1 || event->cpu == smp_processor_id()) &&
- perf_cgroup_match(event) && pmu_filter_match(event);
+ if (event->cpu != -1 && event->cpu != smp_processor_id())
+ return 0;
+ if (!perf_cgroup_match(event))
+ return 0;
+ return pmu_filter_match(event);
}

static void
@@ -3577,7 +3580,11 @@ static int merge_sched_in(struct perf_event_context *ctx,
if (event->state <= PERF_EVENT_STATE_OFF)
return 0;

- if (!event_filter_match(event))
+ /*
+ * Avoid full event_filter_match as the caller verified the CPU and
+ * cgroup before calling.
+ */
+ if (!pmu_filter_match(event))
return 0;

if (group_can_go_on(event, cpuctx, 1)) {
--
2.24.0.393.g34dc348eaf-goog