Discussion:
[libvirt-users] LXC Memory Limits wont work
Markus Raps
2018-08-01 16:06:36 UTC
Permalink
Ok

somehow the processes bypasses the group/namespace

under libvirt the cgroups.procs file (
/sys/fs/cgroup/memory/machine/lxc-4296-deb4.libvirt-lxc/cgroup.procs )
shows only one process

with the lxc tools the cgroups.procs file (
/sys/fs/cgroup/memory/lxc/debian/cgroup.procs )
shows up to all 11 processes
--
Mit freundlichen GrÌßen / best regards
Markus Raps
Daniel P. Berrangé
2018-08-06 08:35:05 UTC
Permalink
Hello,
iam currently trying to run LXC Containers with libvirt
but the memory limit doesn't want to work
in the container i see the full 32GB from the Host OS
iam pretty sure that iam missing a configline in the xml
lxc-template ~ # free -m
total used free shared buff/cache
available
Mem: 32108 626 31396 249 85
31396
Swap: 0 0 0
lxc-template ~ #
The 'free' command reports what is present in the host, which is distinct
from what's made available to the container. This isn't unique to libvirt
LXC containers - in fact any command that is runnning in a cgroup with
memory controller limits applied will see the same behaviour. Apps can't
assume that 'free' reflects the amount of memory that is available to
them. Instead they need to look at cgroups memory controller that they
are placed under (/proc/self/cgroups tells you where)

Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Rene Pasing
2018-08-06 14:53:50 UTC
Permalink
Post by Daniel P. Berrangé
The 'free' command reports what is present in the host, which is distinct
from what's made available to the container. This isn't unique to libvirt
LXC containers - in fact any command that is runnning in a cgroup with
memory controller limits applied will see the same behaviour. Apps can't
assume that 'free' reflects the amount of memory that is available to
them. Instead they need to look at cgroups memory controller that they
are placed under (/proc/self/cgroups tells you where)
I think this is not completely true... I had a similiar problem in the
past, and I could get it fixed by using e.g. this in the domains XML:

  <memtune>
    <hard_limit unit='KiB'>4194304</hard_limit>
    <soft_limit unit='KiB'>4194304</soft_limit>
    <swap_hard_limit unit='KiB'>4194304</swap_hard_limit>
  </memtune>

`free` then reports the correct values. Maybe you can give that a try
@Markus Raps? Of course make sure to check out the documentation[1] of
these config elements to make sure you really want what they do.

Regards
Rene

[1] = https://libvirt.org/formatdomain.html#elementsMemoryTuning

Loading...