public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* KVM clock synchronization
@ 2010-12-29  5:38 Zachary Amsden
  2010-12-29  5:38 ` [KVM Clock Synchronization 1/4] Make cyc_to_nsec conversions more reliable Zachary Amsden
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Zachary Amsden @ 2010-12-29  5:38 UTC (permalink / raw)
  To: kvm

A further set of improvements to KVM clock.  Now it actually can
stay synchronized on SMP systems with a stable TSC, does not get
destabilized by host suspend, and is resistant to migration.

I did look a bit into the second to last remaining migration issue;
that is, we read the TSCs for all VCPUs at different times, then
write them back at different times as well.  We have compensation
for this already (see patch 1), but there is a possibility that
ordering issues create a backwards condition:

  read VTSC-0
  stop VCPU-0
  read VTSC-1
  stop VCPU-1

In that case, what the compensation code does is reset VTSC-1
back to VTSC-0.  With the above ordering, this is broken.

However, in QEMU, the migration order is:

  stop VCPU-0
  stop VCPU-1
  read VTSC-0
  read VTSC-1

So even if a higher TSC value is read for VTSC-1, no backwards
condition can be generated, as VCPU-1 was not running at the time
and thus could not have observed the higher TSC.

This brings us close to having a perfect KVM clock.

Next steps will be testing to see if this in practice allows us
to drop the atomic backwards protection for KVM clock, and if so,
to implement vread so we have fast system calls for time.

Zach


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-01-05 12:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-29  5:38 KVM clock synchronization Zachary Amsden
2010-12-29  5:38 ` [KVM Clock Synchronization 1/4] Make cyc_to_nsec conversions more reliable Zachary Amsden
2010-12-29  5:38 ` [KVM Clock Synchronization 2/4] Keep TSC synchronized across host suspend Zachary Amsden
2011-01-04 15:36   ` Marcelo Tosatti
2011-01-05  4:43     ` Zachary Amsden
2011-01-05 11:44       ` Marcelo Tosatti
2010-12-29  5:38 ` [KVM Clock Synchronization 3/4] Refactor KVM clock update code Zachary Amsden
2010-12-29  5:38 ` [KVM Clock Synchronization 4/4] Add master clock for KVM clock Zachary Amsden
2011-01-04 18:20   ` Marcelo Tosatti
2011-01-04 21:50     ` Zachary Amsden
2011-01-05 12:17 ` KVM clock synchronization Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox