From owner-freebsd-hackers@freebsd.org Fri Feb 24 21:26:31 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4280DCEBDB2 for ; Fri, 24 Feb 2017 21:26:31 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from smtp.vangyzen.net (hotblack.vangyzen.net [IPv6:2607:fc50:1000:7400:216:3eff:fe72:314f]) by mx1.freebsd.org (Postfix) with ESMTP id 2D327954; Fri, 24 Feb 2017 21:26:31 +0000 (UTC) (envelope-from vangyzen@FreeBSD.org) Received: from ford.home.vangyzen.net (unknown [76.164.15.242]) by smtp.vangyzen.net (Postfix) with ESMTPSA id 7DD2D56483; Fri, 24 Feb 2017 15:26:30 -0600 (CST) Subject: Re: Absolute timeouts and clock adjustments To: Ian Lepore , Sebastian Huber , FreeBSD References: <58AD5802.30908@embedded-brains.de> <1ff4d78a-a157-53c5-af7e-b516bc1b6187@FreeBSD.org> <1487778365.73144.144.camel@freebsd.org> From: Eric van Gyzen Message-ID: Date: Fri, 24 Feb 2017 15:26:28 -0600 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <1487778365.73144.144.camel@freebsd.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Feb 2017 21:26:31 -0000 > Using CLOCK_MONOTONIC doesn't avoid the issue, it just explicitly asks > for the current behavior. If the behavior you need is to wake up when > CLOCK_REALTIME exceeds some value, you're still screwed. > > It would be easy enough to fix the current behavior by adding something > like "if (timo > hz) timo = hz;" to the existing loop so that > CLOCK_REALTIME gets re-checked once a second. That would work, but I don't really like introducing spurious wakeups just to handle a very rare event. How about this approach? https://reviews.freebsd.org/D9791 It's also not ideal, and it's obviously much larger than your suggestion, but it's very cheap in the common paths. Eric