Stop KVM guest clock drift from eating your latency budgets

Virtualization (KVM/QEMU/Libvirt)

Stop KVM guest clock drift from eating your latency budgets

Technical Briefing | 7/15/2026

Most of us treat VM time as a given, assuming the host kernel keeps everything in sync. That is true until you hit a high-load scenario where the guest kernel starts missing timer interrupts because the host CPU scheduler had other priorities. I have seen production application logs jump milliseconds out of order, which is a nightmare when you are trying to debug race conditions across distributed services.

Why KVM clocksource matters more than you think

The default clocksource for many Linux guests is kvm-clock. It is generally the right approach, but if your host is oversubscribed, that clock can drift. If you are running timing-sensitive workloads, verify exactly what your guest sees. Relying on the hardware-backed TSC is often faster, but it requires that your host hardware isn’t garbage and you are pinning vCPUs to physical cores to prevent frequency scaling from wreaking havoc on the TSC frequency calculation.

cat /sys/devices/system/clocksource/clocksource0/current_clocksource

  • Check if you are running in hyper-v mode as that provides a more stable TSC page
  • Avoid using acpi_pm as a clocksource because it is remarkably slow and will kill your performance
  • Enable kvm-clock by ensuring the guest kernel has it compiled in or loaded as a module

Pinning and scaling issues

If you don’t pin your vCPUs, the guest might hop between physical cores with different thermal states or C-states. This makes the host TSC variable, which ruins any hope of a synchronized clock. You really should be looking at virsh vcpupin if you care about predictable timing. If you do not pin, you might as well accept that your logs will look like a chaotic scramble during peak traffic.

The next time you see logs that defy causality, stop blaming the app developers. Jump onto the guest, check the clocksource, and verify if your host is actually keeping its promise of a stable TSC. It is usually a boring configuration detail, but it saves you hours of chasing phantom bugs in the code.

Linux Admin Automation  |  © www.ngelinux.com  |  7/15/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted