KVM and cpuunits

MMartinez

Active Member
Dec 11, 2014
42
5
28
Hi,

I would like to priorize some KVM VM over other ones.

I've seen there's a "CPU Units" field in the "CPU Options" button that is available from the hardware tab on the KVM machines.

From the help I read that this option allows to give more CPU to a VM, but, does this apply to KVM Virtual Machines? Or is just to LXC machines...

I've tried to change the CPU Units to many KVM virtual machines and, after setting any different number from default (1024) I can see that the changes are stored in the virtual machine configuration file (i.e: /etc/pve/qemu-server/<vm_id>.conf) under the parameter cpuunit.

Anyway, I think there is something wrong with this, because this parameter is not passed as an argument to the /usr/bin/kvm command (doing a ps I can see that all the other params are passed to it). In fact, as far as I know (after reading the manual), kvm does not have any command line argument to change the cpu priority.

Moreover, I cannot observe any changes in the proxmox node cpu use, after giving a lot of "cpu units" to a test machine and executing a cpu stress on it (for example with the command "stress -c 2 -t 20s" on a linux vm)

I imagine that this parameter only applies to LXC containers, but I prefer to ask here in the forum and be sure of it. Anyway, it would be great to be able to give more cpuunits to priorize some KVM virtual machines, in a similar way as the VMware CPU Shares.

Can you please tell me if this is an interface bug? Is there any way to priorize a KVM machine on a node over the others?

Thanks for your help,

Manuel Martínez
 

dietmar

Proxmox Staff Member
Staff member
Apr 28, 2005
17,124
521
133
Austria
www.proxmox.com
Anyway, I think there is something wrong with this, because this parameter is not passed as an argument to the /usr/bin/kvm command

This is applied to the cgroup directly (not to the kvm binary). I am quite sure this is working. But it is a relative value, so you only see it if you run more VMs at same time ...
 

MMartinez

Active Member
Dec 11, 2014
42
5
28
Ok, thanks.

I'll repeat the tests again. It's extrange, I changed the cpuunits in many VM on a node and I would swear that there was no difference.

In fact, I tried to put a very high value to a VM and I did a cpu stress and I expected to see a big cpu usage on the node but it was the same as without modifying cpuunits on it.

On monday I'll try to do another test. I'll try to stress many vm at the same time, and wait until the job is finished (and not finish it in a fixed time).

Regards,

Manuel
 

MMartinez

Active Member
Dec 11, 2014
42
5
28
Hi dietmar,

I've done some more tests and you were right, it works.

Now I'm doing a cpu stress using the command "stress-ng --cpu 2 --cpu-ops 50000" concurrently on many vm running at the same node (this command does 50000 bogo operations and then stops and gives the execution time).

By changing the cpuunits value for these vm I'm able to determine which ones will finish earlier or later so I can priorize the CPU usage as I wanted.

I didn't know about cgroups and I've found it very usefull.

Thanks lots!

Regards,

Manuel
 

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 your own in 60 seconds.

Buy now!