CPU pinning in KVM

cesarpk

Well-Known Member
Mar 31, 2012
770
3
58
Hi to all.

I have a server with 2 processors of 10 cores and 20 sub-threads (Hyperthreading).

My preoccupation is with the CPU pinning in KVM, i want to reach the max of performance possible taking advantage the cache of processor, and I need to know what configuration should i apply on PVE for get this best performance?.

Please if anybody can explain me how apply the configuration in PVE (I will be using a data base into the KVM VM).

Best regards
Cesar
 
Hi,
use: numactl -H
it will give you output with your processors

#available: 4 nodes (0-3)
#node 0 cpus: 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60
#node 0 size: 32754 MB
#node 0 free: 2407 MB
#node 1 cpus: 1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61
#node 1 size: 32768 MB
#node 1 free: 1926 MB
#node 2 cpus: 2 6 10 14 18 22 26 30 34 38 42 46 50 54 58 62
#node 2 size: 32768 MB
#node 2 free: 2615 MB
#node 3 cpus: 3 7 11 15 19 23 27 31 35 39 43 47 51 55 59 63
#node 3 size: 32768 MB
#node 3 free: 1593 MB
#node distances:
#node 0 1 2 3
# 0: 10 20 20 20
# 1: 20 10 20 20
# 2: 20 20 10 20
# 3: 20 20 20 10


then use:
taskset -a -pc 3,7,11,15,19,23,27,31,35,39,43,47,51,55,59,63 [proces_pid]

it will pin your kvm process to specific processor/cores, do this with all threads from specific kvm machine.
 
Hi zima.

Thank you very much for your reply, I value it very much.

Please let me to do a comments and some questions:

- First, the VM is a MS Windows-Server with MS SQL-Server.
- Second, i want to assign all cores and threads of my hardware to my VM.
- Moreover, sorry for the inconvenience, but I do not understand what you are saying, could you be more clear?
For example:
1) How i should apply the "taskset" for that the changes be permanent?.
2) Node ¿? ¿? ¿? ... is a node a processor socket?

Please have a little patience for me, is the first time that i work in this topic.

Best regards.
Cesar
 
your output of numactl -H should looks like this:


node 0 cpus: 0 2 4 6 8 10 12 14 16 18
...
node 1 cpus: 1 3 5 7 9 11 13 15 17 19


on intel platform phisical cores are counted first interleaved between cpu sockets(nodes) then logical cores in the same fashion.


phisical cores of cpu0 are: 0 2 4 6 8
logical cores of cpu0 are: 10 12 14 16 18


let's assume that we have kvm machine with 4 cores so this machine will generate 4 pids.


exaple of taskset use:


taskset -a -pc 0,2,4,6 our_kvm_pid
and repeat this 4x for all pids
this will give us kvm machine working on 4 phisical cores of cpu0


taskset -a -pc 0,2,10,12 our_kvm_pid
and repeat this 4x for all pids
this will give us kvm machine working on 2 phisical cores and 2 logical cores of cpu0
 
Hy, what is [proces_pid] ?
Can you give us an example how to learn the proces PID for a given VM with an id of 100 ?

Do we Need to run this command everytime we start ProxMox, and before the VMs are started ?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!