[parisc-linux] Re: [PATCH] do_gettimeofday() fails to compensate for lost ticks

Khalid Aziz khalid@fc.hp.com
Wed, 24 Sep 2003 13:01:51 -0600 (MDT)


Turns out the problem is not do_gettimeofday() not accounting for lost
ticks, rather it is do_settimeofday() double compensating for lost
ticks. Here is a patch to fix this problem.

---
Khalid

=========================
--- linux-2.4.22/arch/parisc/kernel/time.c	Thu Nov 28 16:53:10 2002
+++ linux-2.4.22-clock_fix/arch/parisc/kernel/time.c	Wed Sep 24 12:58:36 2003
@@ -191,7 +191,6 @@
 		 * done, and then undo it!
 		 */
 		tv->tv_usec -= gettimeoffset();
-		tv->tv_usec -= (jiffies - wall_jiffies) * (1000000 / HZ);
 
 		while (tv->tv_usec < 0) {
 			tv->tv_usec += 1000000;





> I saw this problem on ia64 and when I checked parisc code, it also seems
> to have the same problem. 
> 
> do_gettimeofday() needs to account for lost ticks before returning
> current time and it fails to do that. do_gettimeofday() on other 
> architectures compensate for lost ticks correctly. Due to this bug, if
> you repeatedly do clock_settime() immediately followed by clock_gettime() 
> and compare the time returned by clock_gettime() to the time set by
> clock_settime(), you will eventually see clock going backwards. I am
> attaching a test program from POSIX testsuite at the end that exposes
> this bug. Run this test in a continuous loop that stops when test fails.
> 
> Following patch should address this issue.
> 
> --
> Khalid
>