Swap accounting regression when running on `cgroup1` system
simondeziel opened this issue · 0 comments
Running the tests/cgroup
test from lxd-ci against 4.0/edge
on GHA works fine and the memory limit test works just fine, see https://github.com/canonical/lxd-ci/actions/runs/10466625686/job/28983825208
==> Testing memory limits
+ MEM_LIMIT_MIB=512
+ lxc config set c1 limits.memory=512MiB
++ lxc exec c1 -- grep '^MemTotal' /proc/meminfo
+ '[' 'MemTotal: 524288 kB' = 'MemTotal: 524288 kB' ']'
+ '[' -e /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes ']'
++ lxc exec c1 -- grep '^SwapTotal' /proc/meminfo
+ '[' 'SwapTotal: 524288 kB' = 'SwapTotal: 524288 kB' ']'
However, when running the same test against latest/candidate
on GHA, it fails when the base OS is 20.04 (cgroup1), see https://github.com/canonical/lxd-ci/actions/runs/10471315694/job/29000643059. Same happens with 5.21/candidate
, see https://github.com/canonical/lxd-ci/actions/runs/10472409214/job/29001816092. Same for 5.0/candidate
, see https://github.com/canonical/lxd-ci/actions/runs/10477645827/job/29019228263. In those cases, it seems that LXD sets swaptotal
to twice the value of limits.memory
:
==> Testing memory limits
+ MEM_LIMIT_MIB=512
+ lxc config set c1 limits.memory=512MiB
++ lxc exec c1 -- grep '^MemTotal' /proc/meminfo
+ '[' 'MemTotal: 524288 kB' = 'MemTotal: 524288 kB' ']'
+ '[' -e /sys/fs/cgroup/memory/memory.memsw.limit_in_bytes ']'
++ lxc exec c1 -- grep '^SwapTotal' /proc/meminfo
+ '[' 'SwapTotal: 1048576 kB' = 'SwapTotal: 524288 kB' ']'
tl;dr: something after 4.0 regressed on cgroup1 systems it seem.