From 28f1fa70692cd37dd09fb924d99ba0cd40e9b2e4 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Tue, 7 Jun 2011 00:23:28 +0200 Subject: [PATCH] --- yaml --- r: 257036 b: refs/heads/master c: b58f6b0dd3d677338b9065388cc2cc942b86338e h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/kernel/events/core.c | 28 +++++++++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/[refs] b/[refs] index 4e720f774d5e..40303b324191 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3ce2a0bc9dfb6423491afe0afc9f099e24b8cba4 +refs/heads/master: b58f6b0dd3d677338b9065388cc2cc942b86338e diff --git a/trunk/kernel/events/core.c b/trunk/kernel/events/core.c index ba89f40abe6a..5e8c7b1389bc 100644 --- a/trunk/kernel/events/core.c +++ b/trunk/kernel/events/core.c @@ -1505,25 +1505,31 @@ static int __perf_install_in_context(void *info) struct perf_event_context *task_ctx = cpuctx->task_ctx; struct task_struct *task = current; - perf_ctx_lock(cpuctx, cpuctx->task_ctx); + perf_ctx_lock(cpuctx, task_ctx); perf_pmu_disable(cpuctx->ctx.pmu); /* * If there was an active task_ctx schedule it out. */ - if (task_ctx) { + if (task_ctx) task_ctx_sched_out(task_ctx); - /* - * If the context we're installing events in is not the - * active task_ctx, flip them. - */ - if (ctx->task && task_ctx != ctx) { - raw_spin_unlock(&cpuctx->ctx.lock); - raw_spin_lock(&ctx->lock); - cpuctx->task_ctx = task_ctx = ctx; - } + + /* + * If the context we're installing events in is not the + * active task_ctx, flip them. + */ + if (ctx->task && task_ctx != ctx) { + if (task_ctx) + raw_spin_unlock(&task_ctx->lock); + raw_spin_lock(&ctx->lock); + task_ctx = ctx; + } + + if (task_ctx) { + cpuctx->task_ctx = task_ctx; task = task_ctx->task; } + cpu_ctx_sched_out(cpuctx, EVENT_ALL); update_context_time(ctx);