From patchwork Fri Sep 5 07:16:27 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: powerpc/spufs: Fix possible scheduling of a context to multiple SPEs Date: Thu, 04 Sep 2008 21:16:27 -0000 From: Andre Detsch X-Patchwork-Id: 185 Message-Id: <200809050416.27831.adetsch@br.ibm.com> To: cbe-oss-dev@ozlabs.org, Jeremy Kerr 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); }