Skip to content

Commit fe45baf

Browse files
virtuosoingomolnar
authored andcommitted
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 <adrian.hunter@intel.com> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Cc: vince@deater.net Link: http://lkml.kernel.org/r/20170119164330.22887-2-alexander.shishkin@linux.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 1fd7e41 commit fe45baf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kernel/events/core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3122,8 +3122,12 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
31223122
* We want to keep the following priority order:
31233123
* cpu pinned (that don't need to move), task pinned,
31243124
* cpu flexible, task flexible.
3125+
*
3126+
* However, if task's ctx is not carrying any pinned
3127+
* events, no need to flip the cpuctx's events around.
31253128
*/
3126-
cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
3129+
if (!list_empty(&ctx->pinned_groups))
3130+
cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
31273131
perf_event_sched_in(cpuctx, ctx, task);
31283132
perf_pmu_enable(ctx->pmu);
31293133
perf_ctx_unlock(cpuctx, ctx);

0 commit comments

Comments
 (0)