Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 04 Oct 2004 11:38:46 -0700
From:      Julian Elischer <julian@elischer.org>
To:        John Baldwin <jhb@freebsd.org>
Cc:        Stephan Uphoff <ups@tree.com>
Subject:   Re: sched_switch (sched_4bsd) may be preempted
Message-ID:  <416198B6.4030801@elischer.org>
In-Reply-To: <200410041321.45142.jhb@FreeBSD.org>
References:  <1096610130.21577.219.camel@palm.tree.com> <200410041321.45142.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help


John Baldwin wrote:

>On Friday 01 October 2004 01:55 am, Stephan Uphoff wrote:
>  
>
>>sched_switch (sched_4bsd) may be preempted in setrunqueue or slot_fill.
>>This could be ugly.
>>Wrapping it into a critical section and resetting TDP_OWEPREEMPT should
>>work.
>>
>>Hand trimmed patch:
>>
>>RCS file: /cvsroot/src/sys/kern/sched_4bsd.c,v
>>retrieving revision 1.65
>>diff -u -r1.65 sched_4bsd.c
>>--- sys/kern/sched_4bsd.c       16 Sep 2004 07:12:59 -0000      1.65
>>+++ sys/kern/sched_4bsd.c       1 Oct 2004 05:35:28 -0000
>>@@ -823,6 +823,7 @@
>>                TD_SET_CAN_RUN(td);
>>        else {
>>                td->td_ksegrp->kg_avail_opennings++;
>>+               critical_enter();
>>                if (TD_IS_RUNNING(td)) {
>>                        /* Put us back on the run queue (kse and all).
>>*/
>>                        setrunqueue(td, SRQ_OURSELF|SRQ_YIELDING);
>>@@ -834,6 +835,8 @@
>>                         */
>>                        slot_fill(td->td_ksegrp);
>>                }
>>+               critical_exit();
>>+               td->td_pflags &= ~TDP_OWEPREEMPT;
>>        }
>>        if (newtd == NULL)
>>                newtd = choosethread();
>>    
>>
>
>I thought that SRQ_YIELDING turned preempting off already.
>  
>
well, that was the intention.. I wonder if there can be more nesting than we expect?




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?416198B6.4030801>