Skip to content

Commit fe45baf

Browse files
virtuosoIngo Molnar
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 <[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]>
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)