On Tue, Nov 08, 2005 at 03:23:19PM -0500, David Zakar wrote:
> Hi all,
>
> Has anyone else noticed that gettimeofday seems to spit out utterly
> bogus values every once in a while, so that time apparently goes
> backwards? I've seen this on an Athlon64 X2 running 2.6.13, a P4 with HT
> running 2.6.12, and two P4s w/o HT running 2.6.12. All were running FC3
> or FC4, but some cursory reading on the Internet would appear to confirm
> this as a general kernel bug of some sort.
>
> Does anyone have a good workaround? This is utterly killing some latency
> testing I'm doing, since I can't trust the results.
Very weird. I would write a quickie test prog:
---
#include <time.h>
#include <stdio.h>
main(){
struct timeval now,then;
gettimeofday(&then,NULL);
sleep(1);
gettimeofday(&now,NULL);
while(timercmp(now,then,>=)
{
then=now; // fun to write, wrt Spaceballs
gettimeofday(&now,NULL);
}
fprintf(stderr,"Time went backwards! Now=%d:%d, then=%d:%d\n",
now.tv_sec,now.tv_usec, then.tv_sec,then.tv_usec);
return 0;
}
---
If you can get this to consistently print the error message, then try
again with xntpd disabled (you don't have some sort of ntpdate/rdate
cronjob to keep the time in sync, do you?). If that still causes
problems, then I would mail the kernel list with the test code and the
fact that you can reproduce it. My thought is that it is probably xntpd
messing with you, but it could be a 64 bit kernel bug...
- Rob
.