Use this when a latency-sensitive VM needs fixed cores, such as real-time, NFV or a database aligned to NUMA.
CPU Pinning
CPU pinning maps each vCPU to a fixed physical core (for example virsh vcpupin or a Proxmox affinity setting) to give latency-sensitive or NUMA-aware workloads predictable performance, at the cost of flexibility and density.
1. Pinning maps vCPUs 1:1 to pCPUs for predictable latency (NFV, real-time).
2. Isolate pinned CPUs from host tasks.
3. Pin within one NUMA node.
4. Pin emulator/IO threads separately.
5. Pinned VMs cannot share those cores.
vCPU → dedicated pCPU
Context & applicabilityCommon mistakes · platform/version boundaries
- Pinning vCPUs to both hyperthreads of the same core for unrelated VMs.
- Pinning without isolating host cores (
isolcpus), so host tasks still run there. - Pinning across NUMA nodes.
- Forgetting emulator and I/O threads, which still run on other cores.
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Checks Verify boundary
virsh vcpupin vm01
virsh emulatorpin vm01
cat /proc/cmdline | grep -o 'isolcpus=[^ ]*'
taskset -pc <qemu-pid>
Pinned vCPUs should map to isolated physical cores on one NUMA node.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Pinning without isolation still shares cores.
- Pinned VMs reduce host flexibility.
- Pin to cores in one NUMA node.
virsh vcpupin <vm> 0 2— pin vCPU 0 to pCPU 2virsh emulatorpin <vm>— pin emulator threadscat /proc/cmdline | grep isolcpus— isolated host CPUs
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
CPU pinning maps each vCPU to a dedicated physical core (or thread), usually combined with isolating those cores from the host scheduler. It gives predictable latency for NFV, real-time, gaming/passthrough and some HPC workloads.
<cputune>
<vcpupin vcpu='0' cpuset='4'/>
<vcpupin vcpu='1' cpuset='5'/>
<emulatorpin cpuset='0-1'/>
</cputune>
# host kernel: isolcpus=4-15 nohz_full=4-15 rcu_nocbs=4-15
Pin within one NUMA node, keep emulator/IO threads on separate cores, and accept that pinned VMs cannot be overcommitted or freely migrated.
ReferenceConfiguration & state1 section · depth on demand
Configuration
virsh vcpupin vm01 0 4 # vCPU 0 → host CPU 4
virsh vcpupin vm01 1 5
virsh emulatorpin vm01 2-3 # QEMU threads elsewhere
virsh vcpuinfo vm01
Documented example, not captured output. Proxmox: affinity: 4-7 in the VM config. For real-time or NFV, also isolate the host cores (isolcpus, nohz_full) and use huge pages, and keep pinned cores within one NUMA node.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in CPU Virtualization → CPU Pinning. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://libvirt.org/docs.html · confidence 94%