Subject: timewarps
To: None <tech-kern@netbsd.org>
From: Chuck Silvers <chuq@chuq.com>
List: tech-kern
Date: 03/09/2002 16:19:49
--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
I've been having trouble on my x86 box (1.4 GHz athlon running -current
from Dec. 10) with getting job-completion stats from tcsh like:
-140462173.440u 1796327214.399s 12:55.99 -2470676.-6% 0+0k 6310+10830io 4812pf+45w
this appears to be due to successive microtime() results showing time
going backwards, which confuses the code that counts process cpu usage.
there are several PRs on this phenomenon on the x86 (11432, 14058, 14100)
and the second of those has the attached test program to see if gettimeofday()
goes backwards. running that program on this box results in an immediate
stream of timewarp events:
1015677774 222667 < 1015677774 222683
1015677774 229281 < 1015677774 239201
1015677774 369218 < 1015677774 379206
1015677774 420365 < 1015677774 420371
1015677774 449220 < 1015677774 459208
1015677774 585061 < 1015677774 585069
1015677774 595786 < 1015677774 595787
1015677774 599237 < 1015677774 609214
1015677774 617182 < 1015677774 617228
1015677774 644164 < 1015677774 644165
1015677774 669226 < 1015677774 679216
1015677774 699230 < 1015677774 709217
1015677774 749231 < 1015677774 759219
1015677774 788984 < 1015677774 788985
1015677774 819265 < 1015677774 829221
1015677774 839303 < 1015677774 849222
1015677774 853113 < 1015677774 853161
1015677774 869333 < 1015677774 879223
1015677774 892475 < 1015677774 892491
1015677774 909070 < 1015677774 909076
1015677774 930222 < 1015677774 930322
1015677774 949527 < 1015677774 949542
1015677774 990116 < 1015677774 990162
1015677775 19388 < 1015677775 29228
1015677775 47335 < 1015677775 47337
however, running the same program on other x86 boxes I have (750 MHZ athlon,
333 MHz P2) shows that those boxes don't get any timewarp events in several
hours. so I'm wondering what's causing this on one box and not the others,
is it the just faster clock speed? or something else?
does the attached program report timewarps for other people?
it would be good to get some more data points.
-Chuck
--6TrnltStXW4iwmi0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="timetest.c"
#include <stdio.h>
#include <sys/time.h>
int
main()
{
struct timeval tv1, tv2;
gettimeofday(&tv2, NULL);
for (;;) {
gettimeofday(&tv1, NULL);
if (tv1.tv_sec < tv2.tv_sec ||
(tv1.tv_sec == tv2.tv_sec && tv1.tv_usec < tv2.tv_usec)) {
printf("%d %d < %d %d\n",
tv1.tv_sec, tv1.tv_usec, tv2.tv_sec, tv2.tv_usec);
}
tv2 = tv1;
}
}
--6TrnltStXW4iwmi0--