Re: [PATCH] Time precision, adjtime(x) vs. gettimeofday

From: Benjamin Herrenschmidt
Date: Wed Oct 08 2003 - 13:44:51 EST



> The following will prevent adjtime from causing time regression.
> It delays starting the adjtime mechanism for one tick, and
> keeps gettimeofday inside the window.
>
> Only fixes i386, but changes to other arch would be similar.
>
> Running a simple clock test program and playing with adjtime demonstrates
> that this fixes the problem (and 2.6.0-test6 is broken).
> But given the fragile nature of the timer code, it should go through some
> more testing before inclusion. Andrew could you put this in the next
> -mm tree?

I like that solution. There is still a possible small issue
in 2.4 but I don't think we need to care about it (see below)

Note about the 2.4 SMP race I talked about, x86 is indeed safe,
as it also uses (jiffies - wall_jiffies) to adjust the offset,
I missed it at first as it's not done from the do_gettimeoffset()
function where I was looking for it.

However, that that means we may apply more than one jiffie to
xtime at once, thus the above workaround would still have a small
hole. But since that happens only with insane interrupt latencies
that I don't expect to see in real life, it's probably a non-issue.

2.6 should always have jiffies and wall_jiffies in perfect sync
as they are manipulated within the same write_lock block.

Ben.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/