> From: Jeremy Fitzhardinge [mailto:jeremy.fitzhardinge@citrix.com]> With this in place, I can do a gettimeofday in about 100ns on a 2.4GHz> Q6600. I'm sure this could be tuned a bit more, but it is > already much better than a syscall.

To evaluate the goodness of this, we really need a fullset of measurements for:

a) cost of rdtsc (and rdtscp if different)b) cost of vsyscall+pvclockc) cost of rdtsc emulatedd) cost of a hypercall that returns "hypervisor system time"

On a E6850 (3Ghz but let's use cycles), I measured;

a == 72 cyclesc == 1080 cyclesd == 780 cycles

It may be partly apples and oranges, but it lookslike a good guess for b on my machine is

b == 240 cycles

Not bad, but is there any additional context switchcost to support it?

> From: Avi Kivity [mailto:avi@redhat.com]> Instead of using vgetcpu() and rdtsc() independently, you can > use rdtscp > to read both atomically. This removes the need for the > preempt notifier.

Xen does not currently expose rdtscp and so does not emulate(or context switch) TSC_AUX. Context switching TSC_AUXis certainly possible, but will likely be expensive.If the primary reason for vsyscall+pvclock is to maximizeperformance for gettimeofday/clock_gettime, this costwould need to be added to the mix.

> preempt notifiers are per-thread, not global, and will upset > the cycle > counters. I'd drop them and use rdtscp instead (and give up if the > processor doesn't support it).

Even if rdtscp is used, in the Intel processor lineuponly the very latest (Nehalem) supports rdtscp, so"give up" doesn't seem like a very good option, at leastin the near future.