I assume you are trying to measure time elapsed from inside of a VM in a guest OS kernel?
If you are running Xen 4.0 or later, you can use the hardware rdtsc instruction to measure elapsed time as it is guaranteed by Xen to be synchronized across cores. Note that unless you are certain that Xen cannot reschedule another VM (including dom0) during your hypercall, you may sometimes see some weird very large measurements which indicate that a scheduling event has occurred.
See docs/misc/tscmode.txt in the Xen source tree (especially the history section) for more information about the TSC.
If you are trying to measure elapsed time IN Xen, see the various CYC_COUNTER macros in xen/common/tmem.c as an example of how this can be done.
From: Srujan Kotikela [mailto:ksrujandas@xxxxxxxxx]
Sent: Friday, March 25, 2011 3:24 PM
To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] Xen System Time
Hi,
Is there any interface for Xen System Time? I am trying to find the average time Xen takes for several operations. I am planning to add small code to hypercall definitions in xen to clock the time to perform that particular functionality.
Are there any functions available in xen which gives time in the Xen kernel. The interface manual talks about "System Time". But I did!
n't find
any functions/hypercalls for that. The only one I found was guest_set_time().