Stop your libvirt guests from getting stuck on host CPU topology

Virtualization (KVM/QEMU/Libvirt)

Stop your libvirt guests from getting stuck on host CPU topology

Technical Briefing | 11/27/2026

You probably copied your VM XML template from a blog post five years ago and haven’t touched it since. It works, sure, but your vCPU placement is likely a disaster. When you don’t explicitly pin vCPUs to physical cores, the Linux scheduler moves your guest threads across the host CPU sockets whenever it feels like it. The result is erratic latency and cache misses that make your high-performance database behave like it is running on a calculator.

The NUMA trap you probably missed

Most sysadmins forget that modern servers have multiple NUMA nodes. If your VM spans across nodes, the guest has to jump over the interconnect to reach memory or other cores. It is a massive performance tax. You need to pin your vCPUs to specific physical cores and match the NUMA nodes to keep the memory access local. Do not trust the hypervisor to optimize this for you; it defaults to the path of least resistance, not the path of most efficiency.

virsh vcpupin instance_name 0 0,2,4,6
virsh numatune instance_name --nodeset 0

  • Check your host topology with lscpu -e to see the actual physical thread mapping
  • Avoid pinning vCPUs to hyper-threaded siblings unless you have no other choice
  • Define strict memory placement in the libvirt domain XML to keep it on the local node

Once you have pinned the threads, check your cache-miss rates. If you still see weird spikes, check if your host has energy-saving features enabled in the BIOS, like C-states that keep waking up the CPU from deep sleep. Just pinning the cores is half the battle, but keeping those cores out of power-save mode is what really keeps the tail latency under control during production traffic.

Linux Admin Automation  |  © www.ngelinux.com  |  11/27/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted