Skip to content

Commit

Permalink
tests/cgroup: check for memory.swap.max in non-root cgroup
Browse files Browse the repository at this point in the history
There is no /sys/fs/cgroup/memory.swap.max file in cgroup tree root
we should look for it in a non-root cgroup instead.

See also LXCFS fix:
lxc/lxcfs@f496e62

Signed-off-by: Alexander Mikhalitsyn <[email protected]>
  • Loading branch information
mihalicyn committed Oct 2, 2024
1 parent 2864b9b commit eeab22d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/cgroup
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ lxc launch "${IMAGE}" c1
echo "==> Validate default values"
[ "$(lxc exec c1 -- nproc)" = "$(nproc)" ]
[ "$(lxc exec c1 -- grep ^MemTotal /proc/meminfo)" = "$(grep ^MemTotal /proc/meminfo)" ]
if [ -e "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes" ] || [ -e "/sys/fs/cgroup/memory.swap.max" ]; then
if [ -e "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes" ] || [ -e "/sys/fs/cgroup/system.slice/memory.swap.max" ]; then
[ "$(lxc exec c1 -- grep ^SwapTotal /proc/meminfo)" = "$(grep ^SwapTotal /proc/meminfo)" ]
else
[ "$(lxc exec c1 -- grep ^SwapTotal /proc/meminfo)" = "SwapTotal: 0 kB" ]
Expand Down Expand Up @@ -110,7 +110,7 @@ echo "==> Testing memory limits"
MEM_LIMIT_MIB=512
lxc config set c1 limits.memory="${MEM_LIMIT_MIB}MiB"
[ "$(lxc exec c1 -- grep ^MemTotal /proc/meminfo)" = "MemTotal: $((MEM_LIMIT_MIB * 1024)) kB" ]
if [ -e "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes" ] || [ -e "/sys/fs/cgroup/memory.swap.max" ]; then
if [ -e "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes" ] || [ -e "/sys/fs/cgroup/system.slice/memory.swap.max" ]; then
[ "$(lxc exec c1 -- grep ^SwapTotal /proc/meminfo)" = "SwapTotal: $((MEM_LIMIT_MIB * 1024)) kB" ]
else
[ "$(lxc exec c1 -- grep ^SwapTotal /proc/meminfo)" = "SwapTotal: 0 kB" ]
Expand All @@ -133,7 +133,7 @@ if [ -e "/sys/fs/cgroup/memory" ]; then
[ "$(lxc exec c1 -- cat /sys/fs/cgroup/memory/memory.swappiness)" = "65" ]
fi

if [ -e "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes" ] || [ -e "/sys/fs/cgroup/memory.swap.max" ]; then
if [ -e "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes" ] || [ -e "/sys/fs/cgroup/system.slice/memory.swap.max" ]; then
lxc config set c1 limits.memory 128MiB
[ "$(lxc exec c1 -- grep ^MemTotal /proc/meminfo)" = "MemTotal: 131072 kB" ]

Expand Down

0 comments on commit eeab22d

Please sign in to comment.