Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1517872

Re: [PATCH] timers: Fix timer inaccuracy

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH] timers: Fix timer inaccuracy
Date 2016-11-09 11:00 +0100
Message-ID <sBxPI-5yX-9@gated-at.bofh.it> (permalink)
References <sBxwl-5sn-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] timers: Fix timer inaccuracy Joonwoo Park <joonwoop@codeaurora.org> - 2016-11-09 10:40 +0100
  Re: [PATCH] timers: Fix timer inaccuracy Thomas Gleixner <tglx@linutronix.de> - 2016-11-09 11:00 +0100
    Re: [PATCH] timers: Fix timer inaccuracy Joonwoo Park <joonwoop@codeaurora.org> - 2016-11-10 02:40 +0100
      Re: [PATCH] timers: Fix timer inaccuracy Thomas Gleixner <tglx@linutronix.de> - 2016-11-10 11:20 +0100

csiph-web