From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752929Ab1JWRK5 (ORCPT ); Sun, 23 Oct 2011 13:10:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38206 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752510Ab1JWRK4 (ORCPT ); Sun, 23 Oct 2011 13:10:56 -0400 Date: Sun, 23 Oct 2011 19:10:33 +0200 From: Gleb Natapov To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Paul Mackerras , Ingo Molnar , Arnaldo Carvalho de Melo Subject: [PATCH] perf: do not set task_ctx pointer in cpuctx if there is no events in the context Message-ID: <20111023171033.GI17571@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do not set task_ctx pointer during sched_in if there is no events associated with the context. Otherwise if during task execution total number of events in the system will become zero perf_event_context_sched_out() will not be called and cpuctx->task_ctx will be left with a stale value. Signed-off-by: Gleb Natapov diff --git a/kernel/events/core.c b/kernel/events/core.c index 0f85778..68b13ee 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -2172,7 +2172,8 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx, perf_event_sched_in(cpuctx, ctx, task); - cpuctx->task_ctx = ctx; + if (ctx->nr_events) + cpuctx->task_ctx = ctx; perf_pmu_enable(ctx->pmu); perf_ctx_unlock(cpuctx, ctx); -- Gleb.