Re: [Patch 1/4] Delay accounting: Initialization

From: Andi Kleen
Date: Tue Nov 15 2005 - 20:48:46 EST


On Wednesday 16 November 2005 02:48, Shailabh Nagar wrote:

>
> Are there problems with using sched_clock()for timestamping if one is prepared
> to live with them not necessarily being nanosecond accurate ? I'm trying to search
> the archives etc. but if you can respond with any quick comments, that'd be very
> helpful.

First it can be relatively slow on P4s (hundreds of cycles)

On other systems it can run with different frequencies on different CPUs,
so you never need to assume a timestamp from one CPU is comparable with
the one from other CPUs (the scheduler carefully avoids this)

If you need a stable timestamp over multiple CPUs don't use it.

In general do_gettimeofday is much safer.
do_gettimeofday shouldn't be that much slower for the case where TSC
works, and where it doesn't there is no other alternative.

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/