From: Andries Brouwer <aebr@win.tue.nl>
To: george anzinger <george@mvista.com>
Cc: Tim Schmielau <tim@physik3.uni-rostock.de>,
Patrick Moor <pmoor@netpeople.ch>,
lkml <linux-kernel@vger.kernel.org>
Subject: Re: time jumps (again)
Date: Tue, 5 Aug 2003 03:08:48 +0200 [thread overview]
Message-ID: <20030805010848.GA4697@win.tue.nl> (raw)
In-Reply-To: <3F2EE053.1020600@mvista.com>
> Tim Schmielau wrote:
> >>What happens: when doing a
> >> $ while true; do date; done
> >>I'm noticing time jumps _exactly_ at the beginning of a "new" second (or
> >>at the end of an "old" one). the jump is exactly 4294 (4295) seconds
> >>into the future. Example:
> >>...
> >>Mon Aug 4 18:11:06 CEST 2003
> >>Mon Aug 4 19:22:41 CEST 2003
> >>Mon Aug 4 18:11:07 CEST 2003
> >>...
> >--- linux-2.4.20/arch/i386/kernel/time.c.orig Mon Aug 4 23:38:47 2003
> >+++ linux-2.4.20/arch/i386/kernel/time.c Mon Aug 4 23:40:53 2003
> >@@ -274,8 +274,8 @@
> > read_lock_irqsave(&xtime_lock, flags);
> > usec = do_gettimeoffset();
> > {
> >- unsigned long lost = jiffies - wall_jiffies;
> >- if (lost)
> >+ long lost = jiffies - wall_jiffies;
> >+ if (lost>0)
> > usec += lost * (1000000 / HZ);
> > }
> > sec = xtime.tv_sec;
At first sight jiffies and wall_jiffies increase monotonically, and
wall_jiffies always has a value jiffies had a moment earlier, so the
difference jiffies - wall_jiffies ought to be nonnegative.
On the other hand, do_gettimeoffset() is a much more obscure function,
and the jumps are also explained if that can return a negative value.
Depending on CONFIG_X86_TSC it does do_slow_gettimeoffset or
do_fast_gettimeoffset. Both offer plenty of opportunities to
return a negative value. Things depend on hardware details.
So, instead of adding a test inside { } I would propose to catch
problems after the {}, e.g. by
if (usec < 0)
usec = 0;
There should be a clue in the fact that the jump happens at the
start of a new second. I don't know what it is.
Andries
next prev parent reply other threads:[~2003-08-05 1:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-04 16:35 time jumps (again) Patrick Moor
2003-08-04 16:37 ` Alan Cox
2003-08-04 21:49 ` Tim Schmielau
2003-08-04 22:38 ` george anzinger
2003-08-05 1:08 ` Andries Brouwer [this message]
2003-08-06 18:16 ` Timothy Miller
2003-08-06 18:55 ` George Anzinger
2003-08-07 0:29 ` Andries Brouwer
2003-08-05 10:32 ` Jan Niehusmann
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=20030805010848.GA4697@win.tue.nl \
--to=aebr@win.tue.nl \
--cc=george@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmoor@netpeople.ch \
--cc=tim@physik3.uni-rostock.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.