From owner-freebsd-arch@FreeBSD.ORG Thu Dec 27 23:21:56 2007 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7D4916A47B for ; Thu, 27 Dec 2007 23:21:56 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from speedfactory.net (mail6.speedfactory.net [66.23.216.219]) by mx1.freebsd.org (Postfix) with ESMTP id 7056E13C468 for ; Thu, 27 Dec 2007 23:21:56 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.8q) with ESMTP id 226289028-1834499 for multiple; Thu, 27 Dec 2007 18:24:08 -0500 Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.8/8.13.8) with ESMTP id lBRNLf8I054109; Thu, 27 Dec 2007 18:21:53 -0500 (EST) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: freebsd-arch@FreeBSD.org Date: Thu, 27 Dec 2007 18:17:28 -0500 User-Agent: KMail/1.9.6 References: <15391.1196547545@critter.freebsd.dk> In-Reply-To: <15391.1196547545@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200712271817.28789.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Thu, 27 Dec 2007 18:21:53 -0500 (EST) X-Virus-Scanned: ClamAV 0.91.2/5270/Thu Dec 27 12:48:18 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Poul-Henning Kamp Subject: Re: New "timeout" api, to replace callout X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Dec 2007 23:21:56 -0000 On Saturday 01 December 2007 05:19:05 pm Poul-Henning Kamp wrote: > > Here is my proposed new timeout API for 8.x. > > The primary objective is to make it possible to have multiple timeout > "providers" of possibly different kind, so that we can have per-cpu > or per-net-stack timeout handing. > > A secondary goal, is to shove the anti-race handling in destruction of > timeouts back into the implemenation, rather than force users to spend > 20+ lines doing that. I don't see this anymore. Perhaps you haven't looked at updated drivers recently? Right now it looks like this: foo_attach/create() { mtx_init(&foo->lock, ...); callout_init_mtx(&foo->callout, &foo->lock); } foo_something() { callout_reset(&foo->callout, foo_timer, ...) } /* Called with lock held */ foo_timer() { /* * Doesn't have to check 'is detaching' or any other such crap * anymore. */ } foo_stop() { FOO_LOCK(); callout_stop(&foo->callout); /* foo_timer() will no longer run after this point. */ FOO_UNLOCK(); } foo_detach/destroy() { foo_stop(); /* * This drain ensures softclock() is done frobbing with our mutex * so we can safely destroy it. Also makes sure it has no references * to our callout structure either. */ callout_drain(&foo->callout); mtx_destroy(&foo->lock); } That's not 20 lines. You have to do the reset/stop anyway and those now work intuitively. The only "extra" code is an init routine (which you will need anyway) and a teardown routine (callout_drain()). From what I can tell, you've basically mandated a lock and when you use callout_init_mtx() (or now callout_init_rw()), callout_stop() == timeout_safe() and callout_drain() == timeout_cleanup(). Thus, as far as the MPSAFEty stuff, I think the timeout changes are just reshuffling deck chairs. The other goals (axeing hz) I agree with, but I don't think you've changed anything as far as MPSAFEty is concerned. Also, I'd probably find timeout_stop() more intuitive than timeout_safe() to be honest. Maybe timeout_disarm()? -- John Baldwin