Re: Fix time going backward with clock=pit [1/2]

From: Roman Zippel
Date: Thu May 18 2006 - 20:09:11 EST


On Thu, 18 May 2006, Tim Mann wrote:

> > I think the whole think should look
> > something like this:
> >
> > if (jiffies_t == jiffies_p) {
> > if (count > count_p) {
> > underflow or crappy timer;
> What should the code do in this case?

Basically the current do_timer_overflow().

> > }
> > } else {
> > jiffies_p = jiffies_t;
> > if (count > LATCH/2 && underflow)
> > count -= LATCH;
> I think I see what you're aiming at here: in the case where we read
> count, then the counter wraps, then we read jiffies, you want to detect
> that and fix it. Actually if you could detect that, the right way to
> fix it would be to set count = LATCH, since the old count is, well, old:
> the current time is right after the jiffy.

It's really "-= LATCH". :)

> However, we don't really have a way to detect that this case happened --
> the "&& underflow" in your code is a handwave.

Ok, I'm not that familiar with Intel hardware (it must be crappier than I
thought). Is there really no way to detect the pending interrupt (e.g.
what do_timer_overflow() does)? Without that information one can really
only guess the time.
It's not that important if it's not completely correct for SMP systems,
they usually have other sources, but for the few systems there this is the
only time source, we should at least make an effort to avoid the read

bye, Roman
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at