Hi,
I’m running LXD 5.21/stable on Ubuntu 24.04.
When I configure “limits.memory: 768MiB” and “limits.memory.enforce:hard” I see that the corresponding cgroup2 files memory.max and memory.swap.max contains the same value 805306368 (e.g., 768MiB in bytes)
Does it mean that the container RAM+SWAP limit is 768MiB? Or, can the container use 768 MiB of RAM and 768 MiB of swap?
Thank you,
Leonid
Hello,
Does it mean that the container RAM+SWAP limit is 768MiB? Or, can the container use 768 MiB of RAM and 768 MiB of swap?
In cgroup-v2 there is no memsw page counter anymore (linux/include/linux/memcontrol.h at 1a1d569a75f3ab2923cb62daf356d102e4df2b86 · torvalds/linux · GitHub). Swap and memory have distinct counters and in your example, it means that container can use 768MiB of RAM and 768MiB of swap at the same time.
Thank you, @amikhalitsyn. I’ve already discovered it experimentally.
It will probably be useful for somebody: LXD defines memory.swap.max value equal to the requested in the limits.memory parameter. But I wanted to have more swap or even remove any limits for the maximum swap size. A solution is to configure “lxc.cgroup2.memory.swap.max” parameter as a raw.lxc parameter in an LXD profile or a container configuration. For example, to remove the swap memory utilization limit in the LXD ‘default’ profile:
lxc profile set default raw.lxc "lxc.cgroup2.memory.swap.max = max"
thanks for sharing your experience with the community!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.