[Cbe-oss-dev] [PATCH] [POWERPC] spufs: don't (ab)use SCHED_IDLE

Jeremy Kerr jk at ozlabs.org
Tue Mar 4 20:17:48 EST 2008


commit 4ef11014 introduced a usage of SCHED_IDLE to detect when
a context is within spu_run.

Instead of SCHED_IDLE (which has other meaning), use an 'int active'
member of struct spu_context to tell if a context should be running.

Signed-off-by: Jeremy Kerr <jk at ozlabs.org>

---
 arch/powerpc/platforms/cell/spufs/context.c |    1 +
 arch/powerpc/platforms/cell/spufs/run.c     |    3 ++-
 arch/powerpc/platforms/cell/spufs/sched.c   |    4 ++--
 arch/powerpc/platforms/cell/spufs/spufs.h   |    3 +++
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index cf6c2c8..79caeb0 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -56,6 +56,7 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang)
 	ctx->state = SPU_STATE_SAVED;
 	ctx->ops = &spu_backing_ops;
 	ctx->owner = get_task_mm(current);
+	ctx->active = 0;
 	INIT_LIST_HEAD(&ctx->rq);
 	INIT_LIST_HEAD(&ctx->aff_list);
 	if (gang)
diff --git a/arch/powerpc/platforms/cell/spufs/run.c b/arch/powerpc/platforms/cell/spufs/run.c
index 6221968..b136171 100644
--- a/arch/powerpc/platforms/cell/spufs/run.c
+++ b/arch/powerpc/platforms/cell/spufs/run.c
@@ -220,6 +220,7 @@ static int spu_run_init(struct spu_context *ctx, u32 *npc)
 		}
 	}
 
+	ctx->active = 1;
 	return 0;
 }
 
@@ -234,7 +235,7 @@ static int spu_run_fini(struct spu_context *ctx, u32 *npc,
 	*npc = ctx->ops->npc_read(ctx);
 
 	spuctx_switch_state(ctx, SPU_UTIL_IDLE_LOADED);
-	ctx->policy = SCHED_IDLE;
+	ctx->active = 0;
 	spu_release(ctx);
 
 	if (signal_pending(current))
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 5d5f680..5e4d307 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -867,7 +867,7 @@ static noinline void spusched_tick(struct spu_context *ctx)
 	if (ctx->policy == SCHED_FIFO)
 		goto out;
 
-	if (--ctx->time_slice && ctx->policy != SCHED_IDLE)
+	if (--ctx->time_slice && ctx->active)
 		goto out;
 
 	spu = ctx->spu;
@@ -877,7 +877,7 @@ static noinline void spusched_tick(struct spu_context *ctx)
 	new = grab_runnable_context(ctx->prio + 1, spu->node);
 	if (new) {
 		spu_unschedule(spu, ctx);
-		if (ctx->policy != SCHED_IDLE)
+		if (ctx->active)
 			spu_add_to_rq(ctx);
 	} else {
 		spu_context_nospu_trace(spusched_tick__newslice, ctx);
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index 2c2fe3c..1cb7f35 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -97,6 +97,9 @@ struct spu_context {
 	int policy;
 	int prio;
 
+	/* this is only set when the context is in spu_run */
+	int active;
+
 	/* statistics */
 	struct {
 		/* updates protected by ctx->state_mutex */



More information about the cbe-oss-dev mailing list