Inaccurate time keeping in KVM RHEL guests under 5.4
Environment
Red Hat Enterprise Linux 5
Red Hat Enterprise Linux 4
Issue
- Virtualized kvm guest running RHEL 5 is not syncing with ntp correctly
- Time appears to be speeding up, moving faster than expected
Resolution
- Run this command to upgrade the guest kernel to kernel-2.6.18-164.15.1 or later:
# yum update kernel - Reboot the system to use the new kernel.
| Release | Recommendations |
|---|---|
| 5.4 AMD64/Intel 64 with the para-virtualized clock | Additional parameters are not required |
| 5.4 AMD64/Intel 64 without the para-virtualized clock | notsc lpj=n |
| 5.4 x86 with the para-virtualized clock | Additional parameters are not required |
| 5.4 x86 without the para-virtualized clock | clocksource=acpi_pm lpj=n |
| 5.3 AMD64/Intel 64 | notsc |
| 5.3 x86 | clocksource=acpi_pm |
| 4.8 AMD64/Intel 64 | notsc |
| 4.8 x86 | clock=pmtmr |
| 3.9 AMD64/Intel 64 | Additional parameters are not required |
| 3.9 x86 | Additional parameters are not required |
The divider kernel parameter was previously recommended for Red Hat Enterprise Linux 4 and 5 guests that did not have high responsiveness requirements, or exist on systems with high guest density. It is no longer recommended for use with guests running Red Hat Enterprise Linux 4, or Red Hat Enterprise Linux 5 versions prior to version 5.8. See Red Hat Enterprise Linux Virtualization Guide.
Root Cause
- The kvmclock source driver was not present so the guest had to rely on NTP syncing. This can cause issues in virtual environments with the way the virtual clock calculates ticks. Some of the important fixes were:
Fixed in 2.6.18-164.1.1 kernel: [x86] kvmclock smp support (Glauber Costa ) [520685 476075] Fixed in 2.6.18-164.1.1 kernel: [x86_64] kvm clocksource's implementation (Glauber Costa ) [520685 476075] - There are a significant number of kvm-clock related fixes in subsequent 5.4 z-stream kernels, upgrading to the latest z-stream is always highly recommended to troubleshoot time-drift related issues.
Diagnostic Steps
- Verify the currently running kernel.
- If the kernel version is less than 2.6.18-164.2.1, then upgrade to at least that kernel release or later if possible
- Review the recommendations made here: KVM Virtual Machine Timing Management
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.