]> git.karo-electronics.de Git - mv-sheeva.git/commit
timekeeping: fix rounding problem during clock update
authorRoman Zippel <zippel@linux-m68k.org>
Mon, 22 Sep 2008 21:42:43 +0000 (14:42 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 24 Sep 2008 15:33:13 +0000 (17:33 +0200)
commit5cd1c9c5cf30d4b33df3d3f74d8142f278d536b7
tree6d74ddeff7e9a044d961d36db13071c158f0557a
parenteb3f938fd6292dc79f43a5fe14784b044776e9f0
timekeeping: fix rounding problem during clock update

Due to a rounding problem during a clock update it's possible for readers
to observe the clock jumping back by 1nsec.  The following simplified
example demonstrates the problem:

cycle xtime
0 0
1000 999999.6
2000 1999999.2
3000 2999998.8
...

1500 = 1499999.4
= 0.0 + 1499999.4
= 999999.6 + 499999.8

When reading the clock only the full nanosecond part is used, while
timekeeping internally keeps nanosecond fractions.  If the clock is now
updated at cycle 1500 here, a nanosecond is missing due to the truncation.

The simple fix is to round up the xtime value during the update, this also
changes the distance to the reference time, but the adjustment will
automatically take care that it stays under control.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: John Stultz <johnstul@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/time/timekeeping.c