提交 075e0b00 编写于 作者: P Peter Zijlstra 提交者: Ingo Molnar

perf: Optimize ctx_sched_out()

Oleg noted that ctx_sched_out() disables the PMU even though it might
not actually do something, avoid needless PMU-disabling.
Reported-by: NOleg Nesterov <oleg@redhat.com>
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20110409192141.665385503@chello.nlSigned-off-by: NIngo Molnar <mingo@elte.hu>
上级 f506b3dc
...@@ -1760,7 +1760,6 @@ static void ctx_sched_out(struct perf_event_context *ctx, ...@@ -1760,7 +1760,6 @@ static void ctx_sched_out(struct perf_event_context *ctx,
struct perf_event *event; struct perf_event *event;
raw_spin_lock(&ctx->lock); raw_spin_lock(&ctx->lock);
perf_pmu_disable(ctx->pmu);
ctx->is_active = 0; ctx->is_active = 0;
if (likely(!ctx->nr_events)) if (likely(!ctx->nr_events))
goto out; goto out;
...@@ -1770,6 +1769,7 @@ static void ctx_sched_out(struct perf_event_context *ctx, ...@@ -1770,6 +1769,7 @@ static void ctx_sched_out(struct perf_event_context *ctx,
if (!ctx->nr_active) if (!ctx->nr_active)
goto out; goto out;
perf_pmu_disable(ctx->pmu);
if (event_type & EVENT_PINNED) { if (event_type & EVENT_PINNED) {
list_for_each_entry(event, &ctx->pinned_groups, group_entry) list_for_each_entry(event, &ctx->pinned_groups, group_entry)
group_sched_out(event, cpuctx, ctx); group_sched_out(event, cpuctx, ctx);
...@@ -1779,8 +1779,8 @@ static void ctx_sched_out(struct perf_event_context *ctx, ...@@ -1779,8 +1779,8 @@ static void ctx_sched_out(struct perf_event_context *ctx,
list_for_each_entry(event, &ctx->flexible_groups, group_entry) list_for_each_entry(event, &ctx->flexible_groups, group_entry)
group_sched_out(event, cpuctx, ctx); group_sched_out(event, cpuctx, ctx);
} }
out:
perf_pmu_enable(ctx->pmu); perf_pmu_enable(ctx->pmu);
out:
raw_spin_unlock(&ctx->lock); raw_spin_unlock(&ctx->lock);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册