On Thu, Jun 14, 2012 at 10:01:33PM +0000, Ted Unangst wrote:
> .
> > 
> >> If neither is true, we don't preempt (thus not calling mpswitch(), not
> >> releasing the kernel lock etc etc).  For this reason it doesn't work
> >> well on SMP.  Unfortunately the above conditions may be false if for ex
> >> 2 processes are spread out across 2 cpus: the cpu with the biglock will
> >> not mark the proc as need-to-switch (because it's the only process on
> >> the runqueue, iirc there's an optimization for that).
> > 
> > I think you remember incorrectly.  As far as I can tell
> > SPCF_SHOULDYIELD is always set when a process overruns its allocated
> > timeslice.
> 
> I think what's meant is that the flag isn't set until the timeslice
> expires. The system will overall be more reactive if we yield the big
> lock before the end of the timeslice. 

Yes.

Digging a bit further, there's another flag that's relevant here:
cpu_info->ci_need_resched, which is set by need_resched().
Unfortunately that's MI (I'd have to check if it's the same everywhere,
I suspect it is).

> > I think it is worth to get this diff tested without worrying about
> > biglock contention first.
> 
> Agreed here. 

Yes.

I'm wondering if
        if (curcpu()->ci_schedstate.spc_schedflags & SPCF_SHOULDYIELD)
                preempt(NULL);
shouldn't be a special function in kern_sched, I suspect its useful for
more parts of the kernel (although I wouldn't know which ones).
-- 
Ariane

Reply via email to