VMware
 

Knowledge Base

Search the Knowledge Base:

Products:
Search In:
 

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.

Solution

Use clock=pmtmr instead of clock=pit and run NTP in the guest to correct for lost tick over compensation. For more information, see Time in a Linux 2.6 guest runs faster than real time due to lost tick overcompensation (1006113).
 
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.

Feedback

Rating: 1 - Lowest 2 3 4 5 - Highest (2 Ratings)   

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.
What can we do to improve this information? (2000 or fewer characters)
Submit
Rating: 1 - Lowest 2 3 4 5 - Highest (2 Ratings)   
Actions