Re: KVM-Clock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Please read https://en.wikipedia.org/wiki/Posting_style or related
documents on email quoting.

2016-02-23 07:11+0000, Avi Cohen:
>> 2016-02-21 16:57+0000, Avi Cohen:
>>> Hello,
>>> 
>>> Last week I've sent a mail regarding the kvm-clock accuracy.
>>> Now I try to draw-up my question again, any answer/partial/hint  is 
>>> greatly appreciated
>>> 
>>> Our application is running in  a Tenant's Virtual Machine in a data-centre.
>>> We have some OAM functions running in  the VMs.
>>> One OAM function is to measure one-way delay between VMa and VMb. 
>>> One way delay measurement requires that all machines should be synchronized to a common central clock.
>>> Accuracy requirement is in order of 10s nano-seconds, hence only the 1588v2/PTP is suitable here.
>>> Since we cannot use HW timestamping in a virtual machine (we cannot force using SR-IOV), I thought to run PTP on the physical machines and to sync the VMs to the host by the kvm-clock.
>> 
>> kvmclock doesn't do synchronization with host clock or UTC.
>> kvmclock bases on host's notion of *passed* time.
>> kvmclock allows the guest to measure a flow of time.
>> 
>> It is another layer's job to translate kvmclock result into a timestamp that can be compared.  kvmclock was designed like that, because KVM wants to make a guest independent on hosts.
> 
> I see the system time written by KVM  whenever the VM is entered  - in  kvm_guest_time_update()
> 
> How can  the guest  (or  another layer's job ) - translate kvmclock result into a timestamp that can be compared ?

If the layer has a good idea about the number of ticks the second takes
on both clocks, then the layer is synchronized with a
  (time on one clock, time on second clock) pair.
You get a timestamp comparable with the other clock by providing a
timestamp from one of synchronized clocks.

The hard part is getting the pair.  (A duration of the second is pretty
stable and the pair needs to be renewed on a change anyway.)

>> > In Theory  - Is it possible to achieve 10s ns accuracy between VM clock and the host clock ? 
>> 
>> It is.
> 
> How ? this is the only question

Look at last paragraph of my previous email.
(That one has 1 ns accuracy if KVM is using the masterclock.)

Note that it is impossible to confirm the accuracy with your measurement
because delay between sending and receiving a packet is normally *far*
longer that 100 ns.

>> > its system_time and the VM_TSC @ current time to the pvclock page , then the guest OS can calculate its current time by:
>> 
>> KVM doesn't write its (= host's) system_time.
>> KVM writes *guest's* system_time.  Guest's system_time at VM_TSC.
>> 
>> (system_time is 0 when the VM starts.  sytem_time can store ~584 years  worth of nanoseconds, but using an arbitrary offset makes everything  simpler.  This part of kvmclock is pretty confusing, so system_time is  likely the source of misunderstanding.)
>> 
>> Have you read that kvmclock does synchronization with host time somewhere?
>> 
> Yes - see - in  vcpu_enter_guest() there is a call to   kvm_guest_time_update()
> 
> Which update  the pvclock paget   for the guest - see that it updates the system_time  with the host system-time 

I think you misunderstand the code, see kvmclock_offset.

system_time is incremented by a second if the host thinks that a second
has passed since last update, but that doesn't allow the guest to tell
host time.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux