[Cbe-oss-dev] [PATCH] [POWERPC] spufs: fix scheduler starvation by idle contexts
Christoph Hellwig
hch at lst.de
Mon Mar 3 15:27:18 EST 2008
On Tue, Feb 19, 2008 at 10:12:48AM +1100, Jeremy Kerr wrote:
> 2.6.25 has a regression where we can starve the scheduler by creating
> (N_SPES+1) contexts, then running them one at a time.
>
> The final context will never be run, as the other contexts are loaded on
> the SPEs, none of which are repoted as free (ie, spu->alloc_state !=
> SPU_FREE), so spu_get_idle() doesn't give us a spu to run on. Because
> all of the contexts are stopped, none are descheduled by the scheduler
> tick, as spusched_tick returns if spu_stopped(ctx).
>
> This change replaces the spu_stopped() check with checking for SCHED_IDLE
> in ctx->policy. We set a context's policy to SCHED_IDLE when we're not
> in spu_run(). We also favour SCHED_IDLE contexts when looking for contexts
> to unbind, but leave their timeslice intact for later resumption.
I'm okay with the algorithm, but please don't use policy == SCHED_IDLE
as the flag for it. SCHED_IDLE is a user-visible and user-settable
scheduler class and we shouldn't overload this. Just use a flag in the
context instead.
More information about the cbe-oss-dev
mailing list