Skip to content

Commit

Permalink
perf: Optimize ctx_sched_out()
Browse files Browse the repository at this point in the history
Oleg noted that ctx_sched_out() disables the PMU even though it might
not actually do something, avoid needless PMU-disabling.

Reported-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20110409192141.665385503@chello.nl
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed May 28, 2011
1 parent f506b3d commit 075e0b0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,6 @@ static void ctx_sched_out(struct perf_event_context *ctx,
struct perf_event *event;

raw_spin_lock(&ctx->lock);
perf_pmu_disable(ctx->pmu);
ctx->is_active = 0;
if (likely(!ctx->nr_events))
goto out;
Expand All @@ -1770,6 +1769,7 @@ static void ctx_sched_out(struct perf_event_context *ctx,
if (!ctx->nr_active)
goto out;

perf_pmu_disable(ctx->pmu);
if (event_type & EVENT_PINNED) {
list_for_each_entry(event, &ctx->pinned_groups, group_entry)
group_sched_out(event, cpuctx, ctx);
Expand All @@ -1779,8 +1779,8 @@ static void ctx_sched_out(struct perf_event_context *ctx,
list_for_each_entry(event, &ctx->flexible_groups, group_entry)
group_sched_out(event, cpuctx, ctx);
}
out:
perf_pmu_enable(ctx->pmu);
out:
raw_spin_unlock(&ctx->lock);
}

Expand Down

0 comments on commit 075e0b0

Please sign in to comment.