From: george anzinger <george@mvista.com>
To: Jamie <jamie@blah123.fsnet.co.uk>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Kernel timers and jiffie wrap-around
Date: Sun, 18 Feb 2001 19:05:13 -0800 [thread overview]
Message-ID: <3A908D69.A9130BCD@mvista.com> (raw)
In-Reply-To: <20001129224354.B07C19F14F@jade.local.jnet>
Jamie wrote:
>
> Hi !
>
> I've been trying to determine the reliability of kernel timers when a box has been up for a while. Now as everyone is aware (for HZ=100 (default)), when the uptime of the kernel reaches (approx.) 1.3 years the clock tick count (jiffies) wraps-around. Now if a kernel timer is added just before the wrap-around then from the source I get the impression the kernel timer will be run immediately instead of after the specified delay. Here's my reasoning:
>
> When adding a timer the internal_add_timer() function is (eventually) called. Given that the current jiffies is close to maximum for an unsigned long value then the following index value is computed:
>
> // jiffies = ULONG_MAX - 10, say.
> // so timer_jiffies is close to jiffies.
> // timer.expires = jiffies + TIMEOUT_VALUE, where TIMEOUT_VALUE=200, say.
>
> index = expires - timer_jiffies;
>
> Thus index is a large negative number resulting in the timer being added to tv1.vec[tv1.index] which means that the timer is run on the next execution of run_timer_list().
Now just how did you arrive at this? What value _is_ ULONG_MAX+190? It
rolls over to 190. But you should think of timer_jiffies as 0-10 (in
your case) so index=190+10 or the desired 200. No need to tweak the
kernel, just try some simple C code. It all works until the requested
time out is greater than ULONG_MAX/2 (about .68 years).
George
snip~
>
> Surely I've misunderstood something in the timer code ?
Now you have a good interview question for that next potential new hire
:)
snip~
prev parent reply other threads:[~2001-02-19 4:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-29 22:43 Kernel timers and jiffie wrap-around Jamie
2001-02-19 3:05 ` george anzinger [this message]
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=3A908D69.A9130BCD@mvista.com \
--to=george@mvista.com \
--cc=jamie@blah123.fsnet.co.uk \
--cc=linux-kernel@vger.kernel.org \
/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