aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Shishkin <[email protected]>2017-01-19 18:43:29 +0200
committerIngo Molnar <[email protected]>2017-01-30 12:01:14 +0100
commitfe45bafbd0e1b5e828aa9d44d07e569df85869a2 (patch)
tree3edb6f4db8cf67e2c38e03301952c2c5e10d7d42
parent1fd7e416995401ec082fc0fe6090a223969beda5 (diff)
perf/core: Don't re-schedule CPU flexible events needlessly
In the sched-in path, we first remove a CPU's flexible events in order to give priority to the task's pinned events. However, this step can be safely skipped if the task doesn't have its own pinned events. This patch implements this skipping. Reported-by: Adrian Hunter <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
-rw-r--r--kernel/events/core.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index d92c7ad7715d..8c0b7334230b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3122,8 +3122,12 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
* We want to keep the following priority order:
* cpu pinned (that don't need to move), task pinned,
* cpu flexible, task flexible.
+ *
+ * However, if task's ctx is not carrying any pinned
+ * events, no need to flip the cpuctx's events around.
*/
- cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
+ if (!list_empty(&ctx->pinned_groups))
+ cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
perf_event_sched_in(cpuctx, ctx, task);
perf_pmu_enable(ctx->pmu);
perf_ctx_unlock(cpuctx, ctx);