Time in a Linux virtual machine jumps backward when using clock=pit
Symptoms
Time jumps backward
Time is off by approximately 1 jiffy
A program that uses the gettimeofday system call sees that the results are not monotonically increasing
Resolution
Background
Occasionally, gettimeofday returns a time that is approximately one jiffy earlier than the previously returned value. If the kernel was compiled with HZ=100, the backward jumps are up to approximately 10ms. If the kernel was compiled with HZ=1000, the backward jumps are up to 1ms. For more information, see Determining the rate of timer interrupts a guest operating system requests (1005802).
An example of a sequence of return values from gettimeofday exhibiting this issue (on a kernel with HZ=1000):
1141873584.825298 seconds
1141873584.825303 seconds
1141873584.824319 seconds (The issue manifests here)
1141873584.824323 seconds
Affected Kernels: Linux 2.6.0 - 2.6.17
Note : This issue is a Linux bug. It can occur on physical hardware as well as virtual hardware.
Note: When using the PM timer for timekeeping (clock=pmtmr in 32bit virtual machines or notsc on 64bit virtual machines) gettimeofday may jump backward by 1us in SMP virtual machines.