Re: [RFC - 0/9] Generic timekeeping subsystem (v. B5)

From: Roman Zippel
Date: Wed Aug 24 2005 - 19:46:28 EST


Hi,

On Wed, 24 Aug 2005, john stultz wrote:

> Ok, well, I'm still at a loss for understanding how this avoids my
> concern about time inconsistencies.

Let's take a simple example to demonstrate the difference between system
time and reference time.
NTP tells us to update the reference time by 1000 units every tick and a
single tick consists of 123 cycles, so the initial multiplier is 8. This
means after 1 tick the system time is 984 and off by -16:

time (ticks) reference time system time mult error
0 0 0 8 0
1 1000 984 8 -16
2 2000 1968 8 -32
3 3000 2952 8 -48
4 4000 3936 9 -64

the error is now big enough, so we speed up system time:

5 5000 5043 9 43
6 6000 6150 8 150

and slow it down again:

7 7000 7134 8 134
8 8000 8118 8 118
9 9000 9102 8 102
10 10000 10086 8 86
11 11000 11070 8 70
12 12000 12054 8 54
13 13000 13038 8 38
14 14000 14022 8 22
15 15000 15006 8 6
16 16000 15990 8 -10
17 17000 16974 8 -26
18 18000 17958 8 -42
19 19000 18942 8 -58
20 20000 19926 8 -74

let's assume we're late with the update by 10 cycles
(gettimeofday=19926+10*8=20006), so a change to the mult also requires a
adjustment of the system time:

20+10 20000 19916 9 -84

so gettimeofday=19916+10*9=20006

21 21000 21023 9 23
22 22000 22130 8 130

now add a single adjustment of 500 to the reference time:

23 23500 23114 11 -386
24 24500 24467 8 -33

A detail which is missing now in my example code is that we actually
should look ahead to the next update, so that multiplier is immediately
adjusted and the error above would never exceed 123/2 unless an update is
delayed.

It's really not that difficult :), it's just important to understand the
difference between reference time and system time. All the NTP adjustments
are done to the reference time and we manipulate the speed of the system
clock to keep it close. The latter has _nothing_ to do with NTP so I don't
want to see anything called like ntp_adj there.

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 http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/