Messages in this thread | | | From | Pasi Savolainen <> | Subject | 2.6.0-test11 brings out gettimeofday() non-monotonicity | Date | Thu, 4 Dec 2003 20:54:08 +0000 (UTC) |
| |
Hi, I (and several others) have had some problems on dual AMD platform with time going backwards. The 2.6.0-test11 -kernel seems to bring it forth very well. I can trigger this behaviour _almost_ every time, simply by running 'updatedb'.
Result is that 'gettimeofday()' starts jumping backwards. I used a program (from earlier gettimeofday() monotonicity discusion), attached below. - - $ ./gtod-test | gawk '{ print $5; }' > avtime # about 30sec here, then ^C $ sort avtime | uniq -c 67 1 - 4 -1:999988 10 -1:999989 3 -1:999990 1 -1:999993 8 -1:999996 12 -1:999997 4 -1:999998 19611 -3:222832 1 -3:222833 - -
On the other hand I recently heard from a developer that monotonic_clock gave in some cases values of about 0xffffffff00000756, which to me looks like a botched 64bit math. This was happening on UP, AMD board.
I've looked at the i386/kernel/time.co/do_gettimeofday(), but don't find any fault with it.
- gettimeofday.c - #include <stdio.h> #include <sys/types.h> #include <sys/time.h>
int main( void ) { int i = 0;
while( 1 ) { struct timeval start; struct timeval stop; struct timeval diff; int rc1; int rc2;
if( i++ % 1000000 == 0 ) printf( "% 12d: Iterations so far\n", i );
rc1 = gettimeofday( &start, 0 ); rc2 = gettimeofday( &stop, 0 ); timersub( &stop, &start, &diff );
if( rc1 < 0 || rc2 < 0 ) printf( " %12d: rc1=%d rc2=%d. Failure!\n", i, rc1, rc2 );
if( diff.tv_sec >= 0 && diff.tv_usec >= 0 ) continue;
printf( "% 12d: Time went backwards: %d:%06d\n", i, diff.tv_sec, diff.tv_usec );
} } - -
-- Psi -- <http://www.iki.fi/pasi.savolainen>
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |