Question regaring correct usage of CPU shares
by mailing-libvirt@posteo.de
Hi there,
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
calculated. Are they calculated on a per core basis? Meaning VM1 and
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?
Thank you.