[Cbe-oss-dev] [PATCH] [POWERPC] spufs: fix scheduler starvation by idle contexts

Luke Browning lukebr at linux.vnet.ibm.com
Fri Feb 29 12:50:40 EST 2008


On Tue, 2008-02-19 at 10:12 +1100, Jeremy Kerr wrote:
> --
> Luke - does this fix the starvation problem?

Yes, it does.   I did the same thing independently with the gang stuff.

Luke

> 
> ---
>  arch/powerpc/platforms/cell/spufs/run.c   |    1 +
>  arch/powerpc/platforms/cell/spufs/sched.c |    8 +++-----
>  2 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/cell/spufs/run.c b/arch/powerpc/platforms/cell/spufs/run.c
> index fca22e1..6221968 100644
> --- a/arch/powerpc/platforms/cell/spufs/run.c
> +++ b/arch/powerpc/platforms/cell/spufs/run.c
> @@ -234,6 +234,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;
>  	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 5915343..3a59721 100644
> --- a/arch/powerpc/platforms/cell/spufs/sched.c
> +++ b/arch/powerpc/platforms/cell/spufs/sched.c
> @@ -856,21 +856,18 @@ static noinline void spusched_tick(struct spu_context *ctx)
>  {
>  	struct spu_context *new = NULL;
>  	struct spu *spu = NULL;
> -	u32 status;
> 
>  	if (spu_acquire(ctx))
>  		BUG();	/* a kernel thread never has signals pending */
> 
>  	if (ctx->state != SPU_STATE_RUNNABLE)
>  		goto out;
> -	if (spu_stopped(ctx, &status))
> -		goto out;
>  	if (ctx->flags & SPU_CREATE_NOSCHED)
>  		goto out;
>  	if (ctx->policy == SCHED_FIFO)
>  		goto out;
> 
> -	if (--ctx->time_slice)
> +	if (--ctx->time_slice && ctx->policy != SCHED_IDLE)
>  		goto out;
> 
>  	spu = ctx->spu;
> @@ -880,7 +877,8 @@ static noinline void spusched_tick(struct spu_context *ctx)
>  	new = grab_runnable_context(ctx->prio + 1, spu->node);
>  	if (new) {
>  		spu_unschedule(spu, ctx);
> -		spu_add_to_rq(ctx);
> +		if (ctx->policy != SCHED_IDLE)
> +			spu_add_to_rq(ctx);
>  	} else {
>  		spu_context_nospu_trace(spusched_tick__newslice, ctx);
>  		ctx->time_slice++;
> _______________________________________________
> cbe-oss-dev mailing list
> cbe-oss-dev at ozlabs.org
> https://ozlabs.org/mailman/listinfo/cbe-oss-dev




More information about the cbe-oss-dev mailing list