Skip to contentSkip to conversation

time does not move forward in HVM guests

DISCUSSION Olaf Hering 2 participants 5 messages Jul 4, 2017 – Jul 5, 2017

lore
Share & tools
lore
#0 lore raw

In my testing with sysbench in a HVM domU running a linux-4.4 based pvops kernel on a xen-4.7 based dom0 the time does not move forward properly:

There (URL below) is basically code like this:
clock_gettime(CLOCK_MONOTONIC, a)
do_work
clock_gettime(CLOCK_MONOTONIC, b)
diff_time(a,b)

All 'do_work' does is writing zeros to a block of memory. clock_getres(CLOCK_MONOTONIC) indicates a resolution of 1ns. If 'do_work' takes like 100ns or less: a==b. I think this is something that should not happen. In case of vcpu overcommit this happens also when 'do_work' takes around 800ns. At some point I have also seen cases of time going backward. I can not reproduce this anymore, might have been bugs in my code or the domU.cfg changed.

A workaround is booting the domU kernel with 'clocksource=tsc nohz=off highres=off'.

Why does this happen? Are the expectations too high?

Olaf

https://github.com/olafhering/sysbench/compare/master...pv
bash autogen.sh
make -j
bash mem.1K.on.sh

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 04.07.17 at 18:34, <[email protected]> wrote:

In my testing with sysbench in a HVM domU running a linux-4.4 based pvops kernel on a xen-4.7 based dom0 the time does not move forward properly:

Quoted 8 lines

There (URL below) is basically code like this:
clock_gettime(CLOCK_MONOTONIC, a)
do_work
clock_gettime(CLOCK_MONOTONIC, b)
diff_time(a,b)

All 'do_work' does is writing zeros to a block of memory. clock_getres(CLOCK_MONOTONIC) indicates a resolution of 1ns.

But what's the implied meaning of resolution here? See below.

Quoted 5 lines

If 'do_work' takes like 100ns or less: a==b. I think this is something that should not happen. In case of vcpu overcommit this happens also when 'do_work' takes around 800ns. At some point I have also seen cases of time going backward. I can not reproduce this anymore, might have been bugs in my code or the domU.cfg changed.

Or did you perhaps test with an older version, where the time handling backports from master hadn't been there yet?

Quoted 2 lines

A workaround is booting the domU kernel with 'clocksource=tsc nohz=off highres=off'.

What clocksource does the system use by default? HPET? According to what the hypervisor tells the guest, vHPET resolution is 16ns. That still wouldn't explain a steady value over a period of 100ns, but it's at least a hint that what the kernel tells you may not be what underlying (virtual) hardware reports.

Additionally - are all three options indeed required to work around this, i.e. no pair out of the three is enough?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 2 lines · Jan Beulich
Quoted 1 line

clock_getres(CLOCK_MONOTONIC) indicates a resolution of 1ns.

But what's the implied meaning of resolution here? See below.

I have no ide what the returned value is supposed to promise.

Quoted 2 lines

Or did you perhaps test with an older version, where the time handling backports from master hadn't been there yet?

It was weeks ago, and I have not seen it since then. I think it is fixed in one way or another.

Quoted 3 lines
Quoted 2 lines

A workaround is booting the domU kernel with 'clocksource=tsc nohz=off highres=off'.

What clocksource does the system use by default? HPET?

HPET would be really really slow. The default clocksource is "xen".

Quoted 5 lines

According to what the hypervisor tells the guest, vHPET resolution is 16ns. That still wouldn't explain a steady value over a period of 100ns, but it's at least a hint that what the kernel tells you may not be what underlying (virtual) hardware reports.

If clocksource=xen relies on the hypervisor, perhaps the kernel should be aware of it in some way. So far I have not checked where clock_getres gets its data.

Quoted 2 lines

Additionally - are all three options indeed required to work around this, i.e. no pair out of the three is enough?

Yes, otherwise the kernel would complain, forgot the exact error message.

Olaf

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 05.07.17 at 09:25, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich
Quoted 1 line

clock_getres(CLOCK_MONOTONIC) indicates a resolution of 1ns.

But what's the implied meaning of resolution here? See below.

I have no ide what the returned value is supposed to promise.

Quoted 2 lines

Or did you perhaps test with an older version, where the time handling backports from master hadn't been there yet?

Quoted 8 lines

It was weeks ago, and I have not seen it since then. I think it is fixed in one way or another.

Quoted 3 lines
Quoted 2 lines

A workaround is booting the domU kernel with 'clocksource=tsc nohz=off highres=off'.

What clocksource does the system use by default? HPET?

HPET would be really really slow. The default clocksource is "xen".

Oh, even for HVM. Doesn't that go back to the missing vDSO support then again, which we had discussed just last week?

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw

Am Wed, 05 Jul 2017 02:14:23 -0600
schrieb "Jan Beulich" <[email protected]>:

Quoted 2 lines

Oh, even for HVM. Doesn't that go back to the missing vDSO support then again, which we had discussed just last week?

Yes. This is part of it. With clocksource=tsc there is a performance boost because vdso is used. With clocksource=hpet there is a performance drop to 20%, depending on the workload, due to the emulation of it (I guess).

Olaf

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel