[lxc-devel] Swap Accounting :Query
Nehal J Wani
nehaljw.kkd1 at gmail.com
Thu Jan 14 17:13:00 UTC 2016
I am using the most recent version of lxcfs, commit:
17f9a5a9d647467e3858fa751e40cc7c022dd475
When I spawn a container with the settings...
lxc.cgroup.memory.limit_in_bytes = 256M
lxc.cgroup.memory.memsw.limit_in_bytes = 512M
... I find that inside the container, we have:
[root at test ~]# free -m
total used free shared buffers cached
Mem: 256 24 231 6 0 20
-/+ buffers/cache: 3 252
Swap: 1023 0 1023
As you can see, the Total swap should have been 256MB, but it is being
shown as ~1GB (same as host). Basically, my memsw setting is being
ignored.
Now, when I revert the patch
https://github.com/lxc/lxcfs/commit/a2de34bad72fb1b30af05d2f39a2b7bc6f20e42d
Then I see the correct usage:
[root at test ~]# free -m
total used free shared buffers cached
Mem: 256 24 231 6 0 20
-/+ buffers/cache: 3 252
Swap: 256 0 256
But off course, this brings back the issue reported at
https://github.com/lxc/lxcfs/issues/60
To fix both the problems, I proposed a patch at:
https://lists.linuxcontainers.org/pipermail/lxc-devel/2016-January/013214.html
which works well for me when host machine is CentOS 7. But fails to
work when the host machine is Ubuntu 15.10
I followed:
https://github.com/torvalds/linux/blob/v4.3/mm/memcontrol.c#L4037
https://github.com/torvalds/linux/blob/v4.3/mm/memcontrol.c#L2893
https://github.com/torvalds/linux/blob/v4.3/include/linux/page_counter.h#L21
To find out that the default value for
/sys/fs/cgroup/memory/lxc/test/memory.memsw.limit_in_bytes is
RES_LIMIT, which is PAGE_COUNTER_MAX * PAGE_SIZE, which is equal to
9223372036854775807 (LONG_MAX) in case of CentOS7 (kernel 3.10.0) and
9223372036854771712 in case of Ubuntu14.04 (kernel 4.2.0). So
assumption of LONG_MAX always is obviously wrong.
Only if somehow lxcfs knew that memsw.limit is not set in the
container configuration...?
--
Nehal J Wani
More information about the lxc-devel
mailing list