[lxc-devel] [PATCH lxcfs] Fix busted swap usage

Serge Hallyn serge.hallyn at ubuntu.com
Sat Jan 9 01:44:19 UTC 2016


Quoting Nehal J Wani (nehaljw.kkd1 at gmail.com):
> When no limit is specified using lxc.cgroup.memory.memsw.limit_in_bytes,
> overflow occurs while calculating Swap{Total,Free}. Commit a2de34b tried
> to fix this, but introduced another bug, wherein if
> memory.memsw.limit_in_bytes >= memory.limit_in_bytes, then Swap{Total,Free}
> are not shown as expected.
> 
> This patch assumes that if memory.memsw.limit_in_bytes is not set, then
> /sys/fs/cgroup/memory/lxc/${CT_NAME}/memory.memsw.limit_in_bytes will have
> the default value = LONG_MAX based on:
> 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
> 
> Fixes #60

With this patch, on a memsw-enabled kernel with no limits set, I get

SwapTotal:      9007199252691856 kB
SwapFree:       9007199252331760 kB


More information about the lxc-devel mailing list