From owner-freebsd-arch@FreeBSD.ORG Mon Oct 4 18:26:25 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C58AB16A4CE for ; Mon, 4 Oct 2004 18:26:25 +0000 (GMT) Received: from duchess.speedfactory.net (duchess.speedfactory.net [66.23.201.84]) by mx1.FreeBSD.org (Postfix) with SMTP id 6EE1B43D2D for ; Mon, 4 Oct 2004 18:26:25 +0000 (GMT) (envelope-from ups@tree.com) Received: (qmail 19133 invoked by uid 89); 4 Oct 2004 18:26:23 -0000 Received: from duchess.speedfactory.net (66.23.201.84) by duchess.speedfactory.net with SMTP; 4 Oct 2004 18:26:23 -0000 Received: (qmail 19102 invoked by uid 89); 4 Oct 2004 18:26:23 -0000 Received: from unknown (HELO palm.tree.com) (66.23.216.49) by duchess.speedfactory.net with SMTP; 4 Oct 2004 18:26:23 -0000 Received: from [127.0.0.1] (localhost.tree.com [127.0.0.1]) by palm.tree.com (8.12.10/8.12.10) with ESMTP id i94IQNmt045033; Mon, 4 Oct 2004 14:26:23 -0400 (EDT) (envelope-from ups@tree.com) From: Stephan Uphoff To: John Baldwin In-Reply-To: <200410041321.45142.jhb@FreeBSD.org> References: <1096610130.21577.219.camel@palm.tree.com> <200410041321.45142.jhb@FreeBSD.org> Content-Type: text/plain Message-Id: <1096914383.44307.25.camel@palm.tree.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 04 Oct 2004 14:26:23 -0400 Content-Transfer-Encoding: 7bit cc: Peter Holm cc: Julian Elischer cc: "freebsd-arch@freebsd.org" Subject: Re: sched_switch (sched_4bsd) may be preempted X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Oct 2004 18:26:25 -0000 On Mon, 2004-10-04 at 13:21, 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. Thanks - I missed that for setrunqueue. However it is needed for maybe_preempt_in_ksegrp and slot_fill. Guess adding a flag parameter and checking for SRQ_YIELDING for both would be and easy way to get rid of the critical section hack. Stephan