Re: [PATCH 1/5] Add a global synchronization point for pvclock

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Zachary Amsden
Date: Friday, April 16, 2010 - 2:05 pm

On 04/16/2010 10:36 AM, Jeremy Fitzhardinge wrote:

This is one source of the problem, but the same thing happens at many 
levels... tsc may start out of sync, drift between sockets, be badly 
re-calibrated by the BIOS, etc... the issue persists even if the TSCs 
are perfectly in sync - the measurement of them is not.

So reading TSC == 100,000 units at time A and then waiting 10 units, one 
may read TSC == 100,010 +/- 5 units because the code stream is not 
perfectly serialized - nor can it be.  There will always be some amount 
of error unless running in perfect lock-step, which only happens in a 
simulator.

This inherent measurement error can cause apparent time to go backwards 
when measured simultaneously across multiple CPUs, or when 
re-calibrating against an external clocksource.  Combined with other 
factors as above, it can be of sufficient magnitude to be noticed.  KVM 
clock is particularly exposed to the problem because the TSC is measured 
and recalibrated for each virtual CPU whenever there is a physical CPU 
switch, so micro-adjustments forwards and backwards may occur during the 
recalibration - and appear as a real backwards time warp to the guest.  
I have some patches to fix that issue, but the SMP problem remains to be 
fixed - and is addressed quite thoroughly by this patch.

Zach
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/5] pv clock misc fixes, Glauber Costa, (Thu Apr 15, 11:37 am)
[PATCH 1/5] Add a global synchronization point for pvclock, Glauber Costa, (Thu Apr 15, 11:37 am)
[PATCH 2/5] change msr numbers for kvmclock, Glauber Costa, (Thu Apr 15, 11:37 am)
[PATCH 3/5] Try using new kvm clock msrs, Glauber Costa, (Thu Apr 15, 11:37 am)
Re: [PATCH 1/5] Add a global synchronization point for pvclock, Jeremy Fitzhardinge, (Fri Apr 16, 1:36 pm)
Re: [PATCH 1/5] Add a global synchronization point for pvclock, Zachary Amsden, (Fri Apr 16, 2:05 pm)
Re: [PATCH 2/5] change msr numbers for kvmclock, Avi Kivity, (Sat Apr 17, 11:51 am)
Re: [PATCH 3/5] Try using new kvm clock msrs, Avi Kivity, (Sat Apr 17, 11:55 am)
Re: [PATCH 1/5] Add a global synchronization point for pvclock, Jeremy Fitzhardinge, (Mon Apr 19, 9:11 am)
Re: [PATCH 1/5] Add a global synchronization point for pvclock, Jeremy Fitzhardinge, (Mon Apr 19, 9:18 am)
Re: [PATCH 1/5] Add a global synchronization point for pvclock, Jeremy Fitzhardinge, (Mon Apr 19, 9:19 am)
Re: [PATCH 1/5] Add a global synchronization point for pvclock, Jeremy Fitzhardinge, (Tue Apr 20, 11:23 am)
Re: [PATCH 1/5] Add a global synchronization point for pvclock, Jeremy Fitzhardinge, (Tue Apr 20, 12:42 pm)
Re: [PATCH 1/5] Add a global synchronization point for pvclock, Jeremy Fitzhardinge, (Fri Apr 23, 12:22 pm)
Re: [PATCH 1/5] Add a global synchronization point for pvclock, Jeremy Fitzhardinge, (Fri Apr 23, 2:35 pm)
Re: [PATCH 1/5] Add a global synchronization point for pvclock, Jeremy Fitzhardinge, (Mon Oct 25, 4:30 pm)
Re: [PATCH 1/5] Add a global synchronization point for pvclock, Jeremy Fitzhardinge, (Tue Oct 26, 10:04 am)