Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

This guide can be used for different applications but it's important to understand my use case scenario. I have about 10 or so "other" VM's on my system that don't need much resources and 1 main Windows 10 VM w/ GPU Passthrough that needs as much horsepower as I can give it for gaming/workstation uses.

I recently upgraded to the Coffee Lake i7 which has 6 cores + HT for 12 possible Threads. If you only have Quad Core, i'd think twice about CPU Pinning, especially if you run other VM's along side your main guest.

CPU Pinning:
My Plan:
I want to give my WindowsVM 4 cores and the rest to be shared between KVM host + Other VM's.

Core 1 & 2 = KVM Host + "Other" VM's 
Core 3-6 = Windows 10 Guest 

Note:  I read it's best to give KVM host Core 0.

Isolate Cores that will be directly Pinned to VCpu's: IE: Block host from being able to use them via Grub

You want to use isolcpu's to block CPU's from being used by the HOST so that they can be assigned to VM Guests. 

Find Core Pairs:

cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | sort | uniq 

Add to grub, update grub and reboot:



#Of VCpu's = # of THREADS
#Set vcpu 0 & 1 to the same physical core and so forth 
#Set CPU's to have 2 Threads per Core

<vcpu placement='static'>8</vcpu> 
<vcpupin vcpu='0' cpuset='2'/> 
<vcpupin vcpu='1' cpuset='8'/> 
<vcpupin vcpu='2' cpuset='3'/> 
<vcpupin vcpu='3' cpuset='9'/> 
<vcpupin vcpu='4' cpuset='4'/> 
<vcpupin vcpu='5' cpuset='10'/> 
<vcpupin vcpu='6' cpuset='5'/> 
<vcpupin vcpu='7' cpuset='11'/> 
<emulatorpin cpuset='0,6'/> 
<cpu mode='host-passthrough' check='none'> 
<topology sockets='1' cores='4' threads='2'/> 

(4 cores * 2 Threads/Core = 8 VCpu's)

Let's make sure it's working!

cat /sys/devices/system/cpu/isolated
cat /sys/devices/system/cpu/possible 
virsh vcpupin Windows10
VCPU: CPU Affinity
0: 2
1: 8
2: 3
3: 9
4: 4
5: 10
6: 5
7: 11
  • This shows that without setting CPU Pin on other VM's they "think" they have full affinity to use any core, but isolcpu's has blocked my cores 3-6 for Windows so all other VM's end up on cores 1 and 2.
virsh vcpuinfo NGinX
[root@kvmatrix ~]# virsh vcpupin NGinX
VCPU: CPU Affinity
0: 0-11
[root@kvmatrix ~]# virsh vcpuinfo NGinX
CPU: 1
State: running
CPU time: 9.2s
CPU Affinity: yyyyyyyyyyyy
[root@kvmatrix ~]# virsh vcpuinfo Confluence
CPU: 1
State: running
CPU time: 59.1s
CPU Affinity: yyyyyyyyyyyy
CPU: 0
State: running
CPU time: 58.6s
CPU Affinity: yyyyyyyyyyyy


  • No labels