From owner-freebsd-current Mon Aug 7 11:28:55 2000 Delivered-To: freebsd-current@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id EC71937BA0B; Mon, 7 Aug 2000 11:28:47 -0700 (PDT) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id e77IQCC08866; Mon, 7 Aug 2000 11:26:12 -0700 (PDT) Date: Mon, 7 Aug 2000 11:26:12 -0700 From: Alfred Perlstein To: Poul-Henning Kamp Cc: Matt Dillon , Mike Smith , Stephen McKay , freebsd-current@FreeBSD.ORG, dillon@FreeBSD.ORG Subject: Re: Ugly, slow shutdown Message-ID: <20000807112612.V4854@fw.wintelcom.net> References: <200008071647.JAA36775@earth.backplane.com> <10026.965667788@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.4i In-Reply-To: <10026.965667788@critter.freebsd.dk>; from phk@critter.freebsd.dk on Mon, Aug 07, 2000 at 07:03:08PM +0200 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Poul-Henning Kamp [000807 10:03] wrote: > In message <200008071647.JAA36775@earth.backplane.com>, Matt Dillon writes: > >:> * Stephen McKay [000805 08:49] wrote: > >:> > > >:> > Patch 2 is smaller and possibly controversial. Normally bufdaemon and > >:> > syncer are sleeping when they are told to suspend. This delays shutdown > >:> > by a few boring seconds. With this patch, it is zippier. I expect people > >:> > to complain about this shortcut, but every sleeping process should expect > >:> > to be woken for no reason at all. Basic kernel premise. > >:> > >:> You better bet it's controversial, this isn't "Basic kernel premise" > >: > >:Actually, that depends. It is definitely poor programming practice to > >:not check the condition for which you slept on wakeup. > >: > >:> *boom* *crash* *ow* :) > >: > >:Doctor: So don't do that. > > > > I gotta agree. This is very bad programming practice. There are many, > > many places in the kernel where tsleep() is called with a 0 delay and > > assumed not to return until something meaningful happens. For example, > > for handling NFS retries, some of the locking code (I think), and I > > could probably find many others. > > Then this code should be changed to do the right thing, which is > to *always* check the condition being slept on before proceeding. Can you give a reason why we'll have to now start coding defensively because our arguments to tsleep() are just "advisory" now? I'm not really sure why for a single reader/writer situation we have to have hysterics for a stray wakeup, it bloats code and is not needed in all places. I can also imagine some fun infinite loops like so: monitor issues wakeup producer wakes and terminates or goes away consumer spins checking on availability Also, one must now do this? timeo = currenttime + 2; while (timeo != currenttime) tsleep(timeo); ? -Alfred To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message