From owner-freebsd-arch@FreeBSD.ORG Tue Nov 28 21:40:25 2006 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7184216A508 for ; Tue, 28 Nov 2006 21:40:25 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id BCFA443CB1 for ; Tue, 28 Nov 2006 21:39:25 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.6/8.13.6) with ESMTP id kASLdMSd015015; Tue, 28 Nov 2006 16:39:23 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-arch@freebsd.org Date: Tue, 28 Nov 2006 16:31:18 -0500 User-Agent: KMail/1.9.1 References: <7105.1163451221@critter.freebsd.dk> In-Reply-To: <7105.1163451221@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200611281631.19224.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]); Tue, 28 Nov 2006 16:39:23 -0500 (EST) X-Virus-Scanned: ClamAV 0.88.3/2255/Tue Nov 28 11:52:00 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,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: a proposed callout API 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: Tue, 28 Nov 2006 21:40:25 -0000 On Monday 13 November 2006 15:53, Poul-Henning Kamp wrote: > The proposed API > ---------------- > > tick_t XXX_ns_tick(unsigned nsec, unsigned *low, unsigned *high); > Caculate the tick value for a given timeout. > Optionally return theoretical lower and upper limits to > actual value, > > tick_t XXX_s_tick(unsigned seconds) > Caculate the tick value for a given timeout. > > The point behind these two functions is that we do not want to > incur a scaling operating at every arming of a callout. Very > few callouts use varying timeouts (and for those, no avoidance > is possible), but for the rest, precalculating the correct > (opaque) number is a good optimization. One note and one question. First, the note. I was planning on rototilling our sleep() APIs to 1) handle multiple locking primitives, and 2) use explicit timescales rather than hz. I had intended on using microseconds with a negative value indicating a relative timeout (so an 'uptime' timeout, i.e. trigger X us from now) and a positive value indicating an absolute timeout (time_t-ish, and subject to ntp changes). Partly because (IIRC) Windows does something similar (negative: relative, positive: absolute, and in microseconds too IIRC) and Darwin as well. Part of the idea was to fix places that abused tsleep(..., 1), etc. to figure out a "real" sleep interval. With your proposal, I would probably change the various sleep routines to take a tick_t instead. That leads me to my question if if you would want to support the notion of absolute vs relative timeouts? Also, my other API change I was going to do was something like this: msleep() -> mtx_sleep() msleep_spin() -> sl_sleep() (or some such, was talking with ups@ at BSDCan about divorcing spin locks from mutexes altogether, including a separate API namespace, since it's practically already separate as it is) new functions such as: rw_sleep(), sx_sleep() (ZFS wants this I think), but this is rather secondary. I'd just rather get the pain and suffering over all at once. -- John Baldwin