Skip to contentSkip to conversation

2.6.0-test11 brings out gettimeofday() non-monotonicity

DISCUSSION Pasi Savolainen 2 participants 2 messages Dec 4, 2003

lore
Share & tools
lore
#0 lore raw

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
                );

        }
}

- -

Signature · 1 line
   Psi -- <http://www.iki.fi/pasi.savolainen>
#1 lore raw
Quoted 2 lines · Pasi Savolainen

I (and several others) have had some problems on dual AMD platform with time going backwards.

Hmmm. Just to double check, you're not running w/ the amd76x_pm module, correct? That module has known issues regarding time.

Quoted 2 lines

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'.

Can you send any more info about the hardware? dmesg and .config as well, please.

Quoted 3 lines

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'd very much like to hear more details about this one. What was the test case, etc?

thanks
-john