RE: kvm-clock again

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

 



> From: Radim Krčmář [mailto:rkrcmar@xxxxxxxxxx]
> Sent: Tuesday, 05 April, 2016 11:25 PM
> To: Avi Cohen
> Cc: kvm@xxxxxxxxxxxxxxx
> Subject: Re: kvm-clock again


> Would you be ok with a wall_time entry in pvclock_vcpu_time_info that would
> tell the host real time at system_time?
> struct pvclock_wall_clock should say the host real time when system_time was
> 0, so it's the same.  wallclock = CLOCK_REALTIME, most likely.
> 
> Creating a new clock would allow us to get rid of many other problems, but your
> goal might be achievable with existing interfaces.
> 
> > I want to enter the KVM  code and try to make a REAL_TIME and accurate
> synchronization between the host and  guest  clocks .
> > Currently I don’t see that KVM  updates the guest’s clock when I manually set
> the host’s clock. I don’t see any impact on the guest’s clock Also after booting
> the guest I see a  diff-time of ~1ms between the 2 clocks.
> > Questions:
> > - What can you tell about the feasibility of this task ?
> 
> Doable.
> 
> > - Can you give me a reference/guides  for this task’s  design ? where to start ?
> potential problems ? pvclock ? when to update , when reentering the VM ? etc..
> 
> Start by using kvm_get_wallclock to pass the host CLOCK_REALTIME into the
> guest and turn wallclock into guest CLOCK_REALTIME.
> 
> A reasonable solution would be to create a thread that periodically synchronizes
> CLOCK_REALTIME with wallclock.  The wallclock thread would behave like
> PTP/NTP, so it should be easy to do.
> (A notification from the host that the wallclock has changed would  be better,
> but needs new interface.)
> 
> I think that using wallclock directly as CLOCK_REALTIME would cause more
> complications:
> - many guest interfaces expect that they can touch CLOCK_REALTIME, but
>   that shouldn't be allowed
Do you mean simultaneously guests write to MSR ? 
Guests running on different physical CPU's can simultaneously write to the MSR and this should trigger kvm update of wall-clock - correct ?
I understand that guest writing to MSR does not necessarily  trigger VM-exit   - correct ?

> - changes in wallclock should trigger guest notifiers as if the change
>   was done by the guest
I don’t understand what do u mean here. 
if for example the host's clock was changed because of PTP time-set, then after some time a guest is writing to MSR to get host real-time clock ,
I expect that the new wall clock update will include this time-set. 
> - wallclock is updated only when the guest writes to the MSR, which
>   would be wasteful for frequent reads and not possible in userspace
> 
As you suggest - this will be performed by a new kernel thread which should only write to the MSR and exit. i.e. it will not look into the wall-clock structure.
Only when user application is requesting the current time (clock_gettime) -  this call (clock_gettime or a another new call) will check the content of the 
pvclock_wall_clock  and calculate the current time.

> We'll have enough experience to decide on followup if no solution using the
> existing framework is acceptable.
��.n��������+%������w��{.n�����o�^n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�

[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