Skip to contentSkip to conversation

common time reference between domU and dom0

DISCUSSION James Harper 6 participants 14 messages Dec 10, 2010

lore
Share & tools
lore
#0 lore raw

I would like to be able to measure front/back ring message latency between a Windows DomU and Dom0. To do this I need a common time reference between the two, preferably with at least microsecond precision (latency <1us is irrelevant for my purposes). Does such a thing exist? A small amount of overhead in measuring this latency is acceptable.

Thanks

James

#1 lore raw

System time, as exposed to guests by Xen, should be good enough.

-- Keir

Quoted 16 lines · James Harper

I would like to be able to measure front/back ring message latency between a Windows DomU and Dom0. To do this I need a common time reference between the two, preferably with at least microsecond precision (latency <1us is irrelevant for my purposes). Does such a thing exist? A small amount of overhead in measuring this latency is acceptable.

Thanks

James

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw
Quoted 3 lines

System time, as exposed to guests by Xen, should be good enough.

How is this exposed for HVM systems?

James

#3 lore raw
Quoted 5 lines · James Harper
Quoted 3 lines

System time, as exposed to guests by Xen, should be good enough.

How is this exposed for HVM systems?

Given all HVM guest time sources are trapped to the hypervisor, including TSC, you may as well just use the HVMOP_get_time hypercall.

-- Keir

Quoted 1 line

James

#4 lore raw
Quoted 1 line

On 10/12/2010 08:23, "James Harper" <[email protected]>

Quoted 8 lines · wrote:
Quoted 6 lines
Quoted 4 lines

System time, as exposed to guests by Xen, should be good enough.

How is this exposed for HVM systems?

Given all HVM guest time sources are trapped to the hypervisor,

including

Quoted 2 lines

TSC, you may as well just use the HVMOP_get_time hypercall.

Is that a new call? I don't see it mentioned in 4.0-testing anywhere.

Is there a fallback if HVMOP_get_time doesn't exist?

James

#5 lore raw
Quoted 3 lines · James Harper

Is that a new call? I don't see it mentioned in 4.0-testing anywhere.

Is there a fallback if HVMOP_get_time doesn't exist?

Not really, but it is really an easy backport to your hypervisor. It will even be in RHEL5.6/CentOS 5.6.

Paolo

#6 lore raw
Quoted 7 lines · Paolo Bonzini
Quoted 3 lines · James Harper

Is that a new call? I don't see it mentioned in 4.0-testing anywhere.

Is there a fallback if HVMOP_get_time doesn't exist?

Not really, but it is really an easy backport to your hypervisor. It will even be in RHEL5.6/CentOS 5.6.

It's probably worth backporting for 4.0.2 too.

-- Keir

Quoted 6 lines

Paolo

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#7 lore raw

Urk. Paolo, I hope Redhat isn't using HVMOP_get_time now as a basis for pvops time? That was one of the purposes of all the tsc work in 4.0 so selecting TSC as the clocksource should have the same result (and IIRC the trap is faster than the hypercall).

Quoted 36 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Friday, December 10, 2010 3:46 AM
To: Paolo Bonzini; James Harper
Cc: [email protected]
Subject: Re: [Xen-devel] Re: common time reference between domU and dom0

Quoted 2 lines · Paolo Bonzini
Quoted 1 line · James Harper

Is that a new call? I don't see it mentioned in 4.0-testing

anywhere.

Quoted 5 lines
Quoted 2 lines

Is there a fallback if HVMOP_get_time doesn't exist?

Not really, but it is really an easy backport to your hypervisor. It will even be in RHEL5.6/CentOS 5.6.

It's probably worth backporting for 4.0.2 too.

-- Keir

Quoted 6 lines

Paolo

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#8 lore raw
Quoted 2 lines · Dan Magenheimer

Urk. Paolo, I hope Redhat isn't using HVMOP_get_time now as a basis for pvops time?

No. I only plan to use it in Windows guests. That said...

Quoted 3 lines

That was one of the purposes of all the tsc work
in 4.0 so selecting TSC as the clocksource should have the same result (and IIRC the trap is faster than the hypercall).

... this has not been backported to RHEL5 though.

Paolo

#9 lore raw
In reply to James Harper
Quoted 7 lines · James Harper
Quoted 1 line

On 10/12/2010 08:23, "James Harper" <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 4 lines

System time, as exposed to guests by Xen, should be good enough.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

How is this exposed for HVM systems?

Given all HVM guest time sources are trapped to the hypervisor,

including

Quoted 2 lines

TSC, you may as well just use the HVMOP_get_time hypercall.

Is that a new call? I don't see it mentioned in 4.0-testing anywhere.

Yeah I think it's in 4.1 only.

Quoted 1 line

Is there a fallback if HVMOP_get_time doesn't exist?

Switch on vtsc (might be default) and just use RDTSC? Might be good enough. I'm not sure that computing system time yourself from fields in shared info works well for HVM guests. HVMOP_get_time I think had been in XenServer patch queue a while and has just been pulled across to upstream.

-- Keir

Quoted 2 lines

James

#10 lore raw
Quoted 16 lines · Keir Fraser
Quoted 14 lines · James Harper
Quoted 1 line

On 10/12/2010 08:23, "James Harper" <[email protected]>

Quoted 8 lines · wrote:
Quoted 6 lines
Quoted 4 lines

System time, as exposed to guests by Xen, should be good enough.

How is this exposed for HVM systems?

Given all HVM guest time sources are trapped to the hypervisor,

including

Quoted 2 lines

TSC, you may as well just use the HVMOP_get_time hypercall.

Quoted 7 lines
Quoted 1 line

Is that a new call? I don't see it mentioned in 4.0-testing anywhere.

Yeah I think it's in 4.1 only.

Quoted 1 line

Is there a fallback if HVMOP_get_time doesn't exist?

Switch on vtsc (might be default) and just use RDTSC? Might be good enough.

IIRC HVMOP_get_time was added because from Windows drivers you can't tell what the Windows kernel has done to the TSC so you can't use it to get system time yourself. It seems to me that exposing the TSC offset alongside the rest of the shared info would fix that but maybe you'd be as well off backporting HVMOP_get_time instead.

Tim.

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Xen Platform Team
Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)
#11 lore raw
In reply to Keir Fraser
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line

How is this exposed for HVM systems?

Given all HVM guest time sources are trapped to the hypervisor,

including

Quoted 2 lines

TSC, you may as well just use the HVMOP_get_time hypercall.

Is that a new call? I don't see it mentioned in 4.0-testing anywhere.

Yeah I think it's in 4.1 only.

Quoted 8 lines
Quoted 1 line

Is there a fallback if HVMOP_get_time doesn't exist?

Switch on vtsc (might be default) and just use RDTSC? Might be good enough.
I'm not sure that computing system time yourself from fields in shared info
works well for HVM guests. HVMOP_get_time I think had been in XenServer patch queue a while and has just been pulled across to upstream.

I believe vtsc will be different in different domains as I believe Xen adjusts it so tsc in any guest effectively starts at zero at time of domain launch. Also, an HVM domain may "write" to tsc and change its effective value.

Also, I'm not sure IIRC, but I think vtsc is never on for dom0.

And IIRC the default for vtsc (vtsc=0) is dependent on the underlying hardware and events (such as migration/save/restore) that transpire. It can be forced on in a vm config file (but again IIRC not for dom0).

See xen-XXX.hg/docs/misc/tscmode.txt for XXX >= 4.0

Dan

#12 lore raw
In reply to Keir Fraser

I was under the impression that none of the domains has the correct time.
Neither Dom0 nor DomU receives a timer interrupt, but only a timer
event. Events that could be missed.
So timing in the millisecond can have jitter and drift.
Is there actually a way to keep a precise timer in a domain?

On top of this I would think that both domains would have to have exclusive access to their own CPU in order to avoid being switched off of the CPU in periods of time(quantums of 30 ms using the default scheduler).

Henry

Quoted 31 lines · Keir Fraser

System time, as exposed to guests by Xen, should be good enough.

 -- Keir

Quoted 9 lines · James Harper

I would like to be able to measure front/back ring message latency between a Windows DomU and Dom0. To do this I need a common time reference between the two, preferably with at least microsecond precision (latency <1us is irrelevant for my purposes). Does such a thing exist? A small amount of overhead in measuring this latency is acceptable.

Thanks

Quoted 7 lines

James

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#13 lore raw

All domains have access to Xen system time, either via hypercall or by calculating it themselves directly given information Xen provides in shared memory. Time interrupt/events can't really be missed - they are delivered synchronously to the guest.

-- Keir

Quoted 50 lines · Henry Pepper

I was under the impression that none of the domains has the correct time.
Neither Dom0 nor DomU receives a timer interrupt, but only a timer
event. Events that could be missed.
So timing in the millisecond can have jitter and drift.
Is there actually a way to keep a precise timer in a domain?

On top of this I would think that both domains would have to have exclusive access to their own CPU in order to avoid being switched off of the CPU in periods of time(quantums of 30 ms using the default scheduler).

Henry

Quoted 26 lines · Keir Fraser

System time, as exposed to guests by Xen, should be good enough.

 -- Keir

Quoted 9 lines · James Harper

I would like to be able to measure front/back ring message latency between a Windows DomU and Dom0. To do this I need a common time reference between the two, preferably with at least microsecond precision (latency <1us is irrelevant for my purposes). Does such a thing exist? A small amount of overhead in measuring this latency is acceptable.

Thanks

Quoted 7 lines

James

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 5 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel