Re: hires timestamps for netif_rx()

From: Andi Kleen (
Date: Fri Jan 18 2002 - 16:07:41 EST

On Fri, Jan 18, 2002 at 12:36:00PM -0800, David S. Miller wrote:
> Andi, the x86 platforms that have SMP have TSC and in that
> case do_get_fast_time == do_gettimeofday and there is no read locking
> :-))))))))))))

Unless I'm misreading the code completely there is readlocking:

void do_gettimeofday(struct timeval *tv)
        unsigned long flags;
        unsigned long usec, sec;

        read_lock_irqsave(&xtime_lock, flags);
        usec = do_gettimeoffset();


      if (cpu_has_tsc) {
                unsigned long tsc_quotient = calibrate_tsc();
                if (tsc_quotient) {
                        do_get_fast_time = do_gettimeofday;

void (*do_get_fast_time)(struct timeval *) = do_normal_gettime;

 * Generic way to access 'xtime' (the current time of day).
 * This can be changed if the platform provides a more accurate (and fast!)
 * version.

void get_fast_time(struct timeval * t)

There would be no locking if get_fast_time used do_gettimeoffset, but it doesn't.

The only lockless i386 gettimeofday i'm aware of is the one in the x86-64 vsyscall
implementation from Andrea.

Anyways. I guess it would hurt to change get_fast_time to gettimeoffset because
it could cause non-monotonies for software that is comparing the socket timestamp
with gettimeofday. A better plan might be to port Andrea's version over to
the generic TSC do_gettimeofday and avoid the lock.


To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to
More majordomo info at

This archive was generated by hypermail 2b29 : Wed Jan 23 2002 - 21:01:13 EST