From owner-freebsd-current@FreeBSD.ORG Thu Jul 22 06:02:04 2004 Return-Path: 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 587D216A4CE for ; Thu, 22 Jul 2004 06:02:04 +0000 (GMT) Received: from out012.verizon.net (out012pub.verizon.net [206.46.170.137]) by mx1.FreeBSD.org (Postfix) with ESMTP id EB74043D3F for ; Thu, 22 Jul 2004 06:02:03 +0000 (GMT) (envelope-from cswiger@mac.com) Received: from [192.168.1.3] ([68.161.120.54]) by out012.verizon.net (InterMail vM.5.01.06.06 201-253-122-130-106-20030910) with ESMTP id <20040722060203.MRDA2198.out012.verizon.net@[192.168.1.3]>; Thu, 22 Jul 2004 01:02:03 -0500 Message-ID: <40FF5851.5080207@mac.com> Date: Thu, 22 Jul 2004 02:01:53 -0400 From: Chuck Swiger Organization: The Courts of Chaos User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707 X-Accept-Language: en-us, en MIME-Version: 1.0 To: John Birrell References: <20040721081310.GJ22160@freebsd3.cimlogic.com.au> <20040721102620.GF1009@green.homeunix.org> <20040721220405.Y2346@epsplex.bde.org> <20040721215940.GK22160@freebsd3.cimlogic.com.au> In-Reply-To: <20040721215940.GK22160@freebsd3.cimlogic.com.au> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Authentication-Info: Submitted using SMTP AUTH at out012.verizon.net from [68.161.120.54] at Thu, 22 Jul 2004 01:02:03 -0500 cc: current@freebsd.org Subject: Re: nanosleep returning early X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2004 06:02:04 -0000 John Birrell wrote: [ ... ] > Bruce, have you seen this document: ? > I'm not looking for a critique here. The document talks about the sleep > overruns in various operatingg systems. There is a patch that was applied > to DragonFly which a[p]plies to the FreeBSD code base too. This was a good link, BTW, John: thanks for the pointer. I've created diffs of containing the first part of the changes for -CURRENT and -STABLE at: http://www.pkix.net/~chuck/timer/timer-STABLE.diff http://www.pkix.net/~chuck/timer/timer-CURRENT.diff On a 4.10 P3-grade machine using HZ=1000, I get the following graphs for 200 seconds worth of the "wakeup.c" program: http://www.pkix.net/~chuck/timer/wakeup001.gif ...so the changes reduce the latency seen from around 1.2ms to around 0.46ms. The aliasing problem is still clearly visible since I haven't had a chance to test the second set of changes. Matt's PLL code in i386/isa/clock.c has diverged a fair amount and the Dfly code apparently no longer works on 486-grade hardware due to using 8254 timing modes, if I understand what's going on correctly, but just the improvement above seems quite worthwhile. I'm going to retest using HZ=100, too, to see what's going on under default conditions. Please note that the wakeup interval after the patch can go very slightly negative (by 5-10 us): I'm not sure whether my hardware clock is off or a little flaky in the microsecond range, whether there is some issue with nanosleep() waking things up a little early, or whether the diffs need to be tweaked more. Testing on a few other machines would be good. :-) -- -Chuck