Add cgroup v2 support to coreclr by omajid · Pull Request #34334 · dotnet/runtime (original) (raw)
Upstream cgroup v2 documentation is available at: https://www.kernel.org/doc/Documentation/cgroup-v2.txt
Some notable differences between cgroup v1 and v2, from a coreclr point of view, include:
- cgroup v2 has a single hierarchy, so we just look for a single "cgroup2" entry in /proc/self/mountinfo (without looking for a subsystem match).
- Since cgroup v2 has a single hierarchy, /proc/self/cgroup generally has a single line "0::/path". There's no need to match subsystems or hierarchy ids here.
- "memory.limit_in_bytes" is now "memory.max". It can contain the literal "max" to indicate no limit.
- "memory.usage_in_bytes" is now "memory.current"
- "cpu.cfs_quota_us" and "cpu.cfs_period_us" have been combined into a single "cpu.max" file with the format "$MAX $PERIOD". The max value can be a literal "max" to indicate a limit is not active.
It is possible to have both cgroup v1 and v2 to both be enabled on a host (but not inside a container). In that case, this change will pick one, which may not be the correct one. We should be able to find the right one by checking the system configuration as described here.