From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753157AbcKIJ7L (ORCPT ); Wed, 9 Nov 2016 04:59:11 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:57319 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbcKIJ6o (ORCPT ); Wed, 9 Nov 2016 04:58:44 -0500 Date: Wed, 9 Nov 2016 10:56:06 +0100 (CET) From: Thomas Gleixner To: Joonwoo Park cc: John Stultz , Eric Dumazet , Frederic Weisbecker , Linus Torvalds , "Paul E. McKenney" , Peter Zijlstra , linux-kernel@vger.kernel.org Subject: Re: [PATCH] timers: Fix timer inaccuracy In-Reply-To: <1478684203-11966-1-git-send-email-joonwoop@codeaurora.org> Message-ID: References: <1478684203-11966-1-git-send-email-joonwoop@codeaurora.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 9 Nov 2016, Joonwoo Park wrote: > When a new timer list enqueued into the time wheel, array index > for the given expiry time is: > > expires = (expires + LVL_GRAN(lvl)) >> LVL_SHIFT(lvl); > idx = LVL_OFFS(lvl) + (expires & LVL_MASK); > > The granularity of the expiry time level is being added to the index > in order to fire the timer after its expiry time for the case when > the timer cannot fire at the exact time because of each level's > granularity. However current index calculation also increases index > of timer list even if the timer can fire at exact time. Consequently > timers which can fire at exact time including all in the first level > of bucket fire with one jiffy delay at present. > > Fix such inaccuracy by adding granularity of expiry time level only > when a given timer cannot fire at exact time. That's simply wrong. We guarantee that the timer sleeps for at least a jiffy. So in case of the first wheel we _must_ increment by one simply because the next jiffie might be immanent and not doing so would expire the timer early. The wheel is not meant to be accurate at all and I really don't want an extra conditional in that path just to make it accurate for some expiry values. That's a completely pointless exercise. Thanks, tglx