From owner-freebsd-current Thu Jul 11 21:28:54 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EE32937B401 for ; Thu, 11 Jul 2002 21:28:50 -0700 (PDT) Received: from web20910.mail.yahoo.com (web20910.mail.yahoo.com [216.136.226.232]) by mx1.FreeBSD.org (Postfix) with SMTP id A432C43E09 for ; Thu, 11 Jul 2002 21:28:50 -0700 (PDT) (envelope-from bsddiy@yahoo.com) Message-ID: <20020712042850.17944.qmail@web20910.mail.yahoo.com> Received: from [218.97.164.167] by web20910.mail.yahoo.com via HTTP; Thu, 11 Jul 2002 21:28:50 PDT Date: Thu, 11 Jul 2002 21:28:50 -0700 (PDT) From: David Xu Subject: Re: Timeout and SMP race To: "Justin T. Gibbs" , Jonathan Lemon Cc: Bruce Evans , bsddiy@yahoo.com, current@FreeBSD.ORG In-Reply-To: <200207120337.g6C3bKbA002490@aslan.scsiguy.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --- "Justin T. Gibbs" wrote: > >I believe I had this conversation with Justin Gibbs earlier; he told > >me that the callout consumers (network, cam) had to be aware of the > >race and handle this if it matters. I don't particularly like complicating > >the callout handlers as illustrated above, though, so if a better scheme > >is possible, that would be nice. > > If callout_stop() is always called from a context that can block and > we desire the semantics that upon return from callout_stop(), you are > not in the callout handler, it seems that this should be quite easy to > achieve. Just track the state of the callout from "commit" and "return", > via some flags locked by a global mutex. If a callout_stop is called > between "commit" and "return" (just look at a global indicating the > currently running callout protected by this mutex), put the thread on a > list to be woken by the thread issuing the callout. To handle the case of > a reschedule performed by the callout itself, the woken up caller to > callout_stop() will have to loop through the test again. In all cases, > the global mutex is only held for very short operations as a leaf mutex. > > >tsleep() is only called from process context > > With interrupt threads, isn't "process context" a bit of a misnomer? > Would it be acceptable for the "interrupt threads" that perform callout_stops > to block waiting for them to take effect? > > -- > Justin I have a patch which is very like what you said here. I set a flag between "commit" and "return", and blocking callout_stop() caller if it is not in softclock() context, the patch still has some problems, for example lock oder reversal which is pointed out by jhb. but Archie Cobbs and others are talking about another resolution, I will set back. David Xu __________________________________________________ Do You Yahoo!? Sign up for SBC Yahoo! Dial - First Month Free http://sbc.yahoo.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message