Re: [libvirt-users] cgroup for VM - does it work properly?

Daniel P. Berrange
Thu, 06 Mar 2014 09:35:20 -0000

On Thu, Mar 06, 2014 at 12:32:28AM +0100, Martin Pavlásek
wrote:
> Hi
>
> I tried to restrict usage of some running VM by cpu.shares (i.e. set to
> 10 from original 1024) on loaded system and it seem doesn't work as I
> expected... all running processes has same CPU usage (by htop) :-/
> Does anyone has same experience?

The cpu.shares variable doesn't provide absolute restriction on
CPU usage, rather it is doing relative prioritization.

eg if you have 2 cgroups that are at the same level in the hierarchy
and you give one shares=512 and one shared=1024, then the latter VM
will get twice the CPU scheduler time of the former. If the latter
VM is completely idle though, the former VM will not be capped in any
way.

If you want absolute caps then you need to use period/quota settings.
Also you want todo this via the   virsh schedinfo   command, not accessing
cgroups directly.

Regards,
Daniel
--
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|