Re: Question regaring correct usage of CPU shares

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 12, 2023 at 11:36:36AM +0000, mailing-libvirt@xxxxxxxxx wrote:
Hi there,


Hi, sorry for the late answer.

I have a question regarding the shares option of the cputune section. I
want to illustrate my question with the following example. Let's assume
I have two virtual machines like the following on four dedicated core
with two threads each:

VM1:
<cputune>
 <shares>512</shares>
 <vcpupin vcpu="0" cpuset="0"/>
 <vcpupin vcpu="1" cpuset="4"/>
</cputune>

VM2:
cputune>
 <shares>512</shares>
 <vcpupin vcpu="0" cpuset="1"/>
 <vcpupin vcpu="1" cpuset="5"/>
 <vcpupin vcpu="2" cpuset="2"/>
 <vcpupin vcpu="3" cpuset="6"/>
 <vcpupin vcpu="4" cpuset="3"/>
 <vcpupin vcpu="5" cpuset="7"/>
</cputune>

Those two virtual machines I just mentioned won't interfere with one
another since they are pinned to different cores. However I introduce
another, third virtual machine, like this:

VM3:
<cputune>
 <shares>512</shares>
 <vcpupin vcpu="0" cpuset="0"/>
 <vcpupin vcpu="1" cpuset="4"/>
 <vcpupin vcpu="2" cpuset="1"/>
 <vcpupin vcpu="3" cpuset="5"/>
 <vcpupin vcpu="4" cpuset="2"/>
 <vcpupin vcpu="5" cpuset="6"/>
 <vcpupin vcpu="6" cpuset="3"/>
 <vcpupin vcpu="7" cpuset="7"/>
</cputune>

What I want is that VM1, VM2 and VM3 all receive half of the cores CPU
time if congestion appears. My question is how the shares are

That is what should, theoretically, happen, yes.  And it does not matter
if the value is 512, 7 or 20000.

calculated. Are they calculated on a per core basis? Meaning VM1 and

No, they are set per-VM.

VM3 use the first core so each will get half of the cores capacity when
congestion appears, or are the shares calculated over all cores a
virtual machine uses and I need to scale the amount of shares with
increasing number of cores. What is the correct setting here so that
all virtual machines in this example are guaranteed half of the
capacity of each of their respective cores if congestion appears?


The above is okay from this point of view.  But it depends on the rest
of your system.  What scheduler you have, what are the other processes
running, etc.  You can have a look at the settings in cgroups (in v1
this is cpu.shares, in v2 I think that's cpu.weight) and see how they
are set.

Hope that helps,
Martin

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux