Inaccurate time keeping in KVM RHEL guests under 5.4

Solution Verified - Updated

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

  1. Run this command to upgrade the guest kernel to kernel-2.6.18-164.15.1 or later:
    # yum update kernel
    
  2. Reboot the system to use the new kernel.
If this is not possible, consider adding the following arguments to the boot line prompt in `/etc/grub/grub.conf`
ReleaseRecommendations
5.4 AMD64/Intel 64 with the para-virtualized clockAdditional parameters are not required
5.4 AMD64/Intel 64 without the para-virtualized clocknotsc lpj=n
5.4 x86 with the para-virtualized clockAdditional parameters are not required
5.4 x86 without the para-virtualized clockclocksource=acpi_pm lpj=n
5.3 AMD64/Intel 64notsc
5.3 x86clocksource=acpi_pm
4.8 AMD64/Intel 64notsc
4.8 x86clock=pmtmr
3.9 AMD64/Intel 64Additional parameters are not required
3.9 x86Additional 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

  1. Verify the currently running kernel.
  2. 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
  3. Review the recommendations made here: KVM Virtual Machine Timing Management
SBR
Components
Category
Tags

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.