From: john stultz <johnstul@us.ibm.com>
To: David Vrabel <dvrabel@arcom.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>, mann@vmware.com
Subject: Re: Jiffy based timers/timeouts can expire too soon.
Date: Thu, 02 Dec 2004 10:47:27 -0800 [thread overview]
Message-ID: <1102013246.13294.19.camel@cog.beaverton.ibm.com> (raw)
In-Reply-To: <41AF3D50.4090707@arcom.com>
On Thu, 2004-12-02 at 08:05, David Vrabel wrote:
> Jiffy based timers and timeouts can expire too soon because the timer
> interrupt accounts for lost ticks and can increment jiffies by more than 1.
>
> Consider the following:
>
> unsigned long timeout = jiffies + 1;
>
> <--- timer interrupt here:
> jiffies += 2 (i.e., catching up one missed interrupt)
>
> if (time_after(jiffies, timeout))
> /* but 1 tick worth of time hasn't (necessarily) elapsed */
Well, hopefully the lost tick detection code won't over compensate, so
it shouldn't be an issue. However, as Tim Mann pointed out it, due to
interrupt delay and queuing, it is seen on virtualized systems.
See http://www.ussg.iu.edu/hypermail/linux/kernel/0411.2/2293.html for
his explanation.
> This was originally observed on an ARM platform[1] but the i386 timer
> interrupt appears to behave in a similar way.
>
> Is this solution here to:
>
> 1. Not use jiffies for timers/timeouts with only a few ticks?
>
> or
>
> 2. Have two independant "jiffies": the existing one which is used for
> the wallclock only; and one which counts the number of timer interrupts
> and will guarantee that timers don't expire prematurely?
>
> or
>
> 3. Something else?
Ideally (in my mind), we need to first get a stable and reliable time
base that isn't affected by lost interrupts. This is what I've been
(unfortunately not very frequently) working on w/ my time of day re-work
(See http://lwn.net/Articles/100665/ - although this is somewhat out of
date as I've been re-working some bits and need to post a new set of
patches soon).
Once that is done, we can convert the timer subsystem to use units of
nanoseconds, rather then jiffies for its time accounting. Interrupt
delay, loss, and queuing then become a latency issue, rather then a
correctness one.
However, patches speak louder then words (and I need to do less talking
and more coding), so don't let me keep you from implementing your own
solution.
thanks
-john
next prev parent reply other threads:[~2004-12-02 18:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-02 16:05 David Vrabel
2004-12-02 16:35 ` Chris Friesen
2004-12-02 18:47 ` john stultz [this message]
2004-12-02 23:28 ` Anton Blanchard
2004-12-16 20:38 ` George Anzinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1102013246.13294.19.camel@cog.beaverton.ibm.com \
--to=johnstul@us.ibm.com \
--cc=dvrabel@arcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mann@vmware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®