From: Jim Paris <jim@jtan.com>
To: linux-kernel@vger.kernel.org
Subject: Re: time() glitch on 2.4.18: solved
Date: Sun, 3 Nov 2002 14:32:16 -0500 [thread overview]
Message-ID: <20021103143216.A27147@neurosis.mit.edu> (raw)
In-Reply-To: <20021102013704.A24684@neurosis.mit.edu>; from jim@jtan.com on Sat, Nov 02, 2002 at 01:37:04AM -0500
> The problem is with time(). Every second, for approximately 1.1ms,
> time() reports a value that is about 2^32 microseconds (4295 seconds,
> or about an hour and a quarter) in the future. The glitches always
> occur between a change of seconds.
I finally found the problem.
My i8253 was out of phase. The 16-bit timer value is read in two
8-bit reads from the 8253 in arch/i386/kernel/time.c, and this value
should be between 0 and LATCH-1. My kernel was getting the MSB and
LSB reversed, and so the read values were usually too high, and
delay_at_last_interrupt ended up negative. This caused some small
random negative amount to be subtracted from usecs during
do_gettimeofday, and so my clock was always making small jumps
backwards, and occasionally jumping forward 2^32 when usecs was small.
To fix it, I just read a single byte from port 0x40. If I do it
again, the problem returns (and I've tested that this is the case on
multiple systems, so it's not just a problem with my 8253).
After 180 days of uptime, it's not surprising that there would have
been one read of the port that failed, triggering the problem, so I
think the kernel should detect and fix this. We could just check for
it: if the returned count > LATCH, read an extra byte from port 0x40,
as I did. Or, use the method in do_slow_gettimeoffset, which
basically resets the 8253's counter if count > LATCH.
Any comments?
-jim
next prev parent reply other threads:[~2002-11-03 19:25 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-02 6:37 time() glitch on 2.4.18 at 177 days uptime? Jim Paris
2002-11-03 19:32 ` Jim Paris [this message]
2002-11-03 20:30 ` time() glitch on 2.4.18: solved Alan Cox
2002-11-05 16:30 ` [PATCH] " Jim Paris
2002-11-05 16:54 ` george anzinger
2002-11-05 17:10 ` Willy Tarreau
2002-11-05 18:16 ` Alan Cox
2002-11-05 18:02 ` Jim Paris
2002-11-05 18:37 ` Alan Cox
2002-11-05 18:20 ` Willy Tarreau
2002-11-05 18:50 ` Jim Paris
2002-11-05 17:14 ` Willy Tarreau
2002-11-05 17:42 ` Jim Paris
2002-11-05 18:57 ` Richard B. Johnson
2002-11-05 19:08 ` Willy Tarreau
2002-11-05 19:29 ` Richard B. Johnson
2002-11-05 20:07 ` Alan Cox
2002-11-05 20:14 ` Willy Tarreau
2002-11-05 20:38 ` Richard B. Johnson
2002-11-05 23:15 ` Willy Tarreau
2002-11-06 12:47 ` Richard B. Johnson
2002-11-06 13:25 ` Alan Cox
2002-11-06 23:21 ` Jim Paris
2002-11-05 20:23 ` Richard B. Johnson
2002-11-05 20:57 ` Alan Cox
2002-11-05 20:41 ` Richard B. Johnson
2002-11-06 15:09 ` Christer Weinigel
2002-11-06 15:49 ` Richard B. Johnson
2002-11-05 20:06 ` Alan Cox
2002-11-05 17:32 ` Alan Cox
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=20021103143216.A27147@neurosis.mit.edu \
--to=jim@jtan.com \
--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
all inboxes | Powered by JetHome®