From patchwork Fri Sep 5 07:16:27 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Detsch X-Patchwork-Id: 185 X-Patchwork-Delegate: jk@ozlabs.org Return-Path: X-Original-To: patchwork@ozlabs.org Delivered-To: patchwork@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 7C472DDF7C for ; Fri, 5 Sep 2008 17:17:52 +1000 (EST) X-Original-To: cbe-oss-dev@ozlabs.org Delivered-To: cbe-oss-dev@ozlabs.org Received: from igw3.br.ibm.com (igw3.br.ibm.com [32.104.18.26]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "igw3.br.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id D97ABDDF60; Fri, 5 Sep 2008 17:17:36 +1000 (EST) Received: from mailhub3.br.ibm.com (unknown [9.18.232.110]) by igw3.br.ibm.com (Postfix) with ESMTP id BE19F390158; Fri, 5 Sep 2008 03:56:34 -0300 (BRST) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by mailhub3.br.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m857HZlh3936442; Fri, 5 Sep 2008 04:17:35 -0300 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m857HSQO017221; Fri, 5 Sep 2008 04:17:28 -0300 Received: from [9.18.200.217] ([9.18.200.217]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m857HRI3016984; Fri, 5 Sep 2008 04:17:28 -0300 From: Andre Detsch To: cbe-oss-dev@ozlabs.org, Jeremy Kerr Date: Fri, 5 Sep 2008 04:16:27 -0300 User-Agent: KMail/1.9.6 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200809050416.27831.adetsch@br.ibm.com> Subject: [Cbe-oss-dev] [PATCH] powerpc/spufs: Fix possible scheduling of a context to multiple SPEs X-BeenThere: cbe-oss-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Discussion about Open Source Software for the Cell Broadband Engine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org Errors-To: cbe-oss-dev-bounces+patchwork=ozlabs.org@ozlabs.org We currently have a race when scheduling a context to a SPE - after we have found a runnable context in spusched_tick, the same context may have been scheduled by spu_activate(). This may result in a panic if we try to unschedule a context that has been freed in the meantime. This change exits spu_schedule() if the context has already been scheduled, so we don't end up scheduling it twice. Signed-off-by: Andre Detsch Index: spufs/arch/powerpc/platforms/cell/spufs/sched.c =================================================================== --- spufs.orig/arch/powerpc/platforms/cell/spufs/sched.c +++ spufs/arch/powerpc/platforms/cell/spufs/sched.c @@ -727,7 +727,8 @@ static void spu_schedule(struct spu *spu /* not a candidate for interruptible because it's called either from the scheduler thread or from spu_deactivate */ mutex_lock(&ctx->state_mutex); - __spu_schedule(spu, ctx); + if (ctx->state == SPU_STATE_SAVED) + __spu_schedule(spu, ctx); spu_release(ctx); }