lxc / lxcfs

FUSE filesystem for LXC
https://linuxcontainers.org/lxcfs
Other
1.02k stars 246 forks source link

Fix swap handling for cgroups v2 #617

Closed alexhudspith closed 3 months ago

alexhudspith commented 8 months ago

This should resolve the issues with swap reporting with cgroups v2. It consists of 3 commits which are logically separated. First PR here, feedback welcome 😃

proc_fuse: Fix get_swap_info typo swtotal == 0 -> *swtotal == 0

proc: Fix swap handling for cgroups v2 (can_use_swap)

On cgroups v2, there are no swap current/max files at the cgroup root, so can_use_swap must look lower in the hierarchy to determine if swap accounting is enabled. To also account for memory accounting being turned off at some level, walk the hierarchy upwards from lxcfs' own cgroup.

proc: Fix swap handling for cgroups v2 (zero limits)

Since memory.swap.max = 0 is valid under v2, limits of 0 must not be treated differently. Instead, use UINT64_MAX as the default limit. This aligns with cgroups v1 behaviour anyway since 'limit_in_bytes' files contain a large number for unspecified limits (2^63).

Resolves: #534

mihalicyn commented 3 months ago

Hi @alexhudspith

Amazing work! Sorry about such a big delay with review.

Couldn't you force push it to trigger CI tests?

alexhudspith commented 3 months ago

Hi @alexhudspith

Amazing work! Sorry about such a big delay with review.

Couldn't you force push it to trigger CI tests?

Thanks! Should I redo the last commit on my branch to force push? Not sure how the CI trigger works.

mihalicyn commented 3 months ago

Thanks! Should I redo the last commit on my branch to force push? Not sure how the CI trigger works.

easiest thing you can do to trigger CI is:

git commit --amend
# change nothing
git push -f
alexhudspith commented 3 months ago

easiest thing you can do to trigger CI is: ...

Thanks both. Force pushed with no changes.