Re: rdtscp vgettimeofday

dean gaudet
2006-12-11T21:17:26Z

On Mon, 11 Dec 2006, Andrea Arcangeli wrote:

> As far as I can see, many changes happened but nobody has yet added
> the rdtscp support to x86-64. rdtscp finally solves the problem and it
> obsoletes hpet for timekeeping and it allows a fully userland
> gettimeofday running at maximum speed in userland.

rdtscp doesn't solve anything extra which can't already be solved with
existing vgetcpu (based on lsl) and rdtsc. which have the advantage of
working on all x86, not just the (currently) rare revF opteron.

lsl-based vgetcpu is relatively slow (because it is a protected
instruction with lots of microcode) -- but there are other options which
continue to work on all x86 (see <http://lkml.org/lkml/2006/11/13/401>).

> Before rdtscp we could never index the rdtsc offset in a proper index
> without being in kernel with preemption disabled, so it could never
> work reliably.

even with rdtscp you have to deal with the definite possibility of being
scheduled away in the middle of the computation. arguably you need to
deal with the possibility of being scheduled away *and* back again to the
same cpu (so testing cpu# at top and bottom of a loop isn't sufficient).

suleiman proposed a per-cpu scheduling event number to deal with that...
not sure what folks think of that idea.

-dean