-
Notifications
You must be signed in to change notification settings - Fork 24
Add cgroupv2 support #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
/triage accepted |
Here is a design doc I've written for how these changes should work (implementation in #140): In order to add support in usage-metrics-collector for cgroupv2 systems, we must address the following:
Note: usage-metrics-collector documents cgroupv1 metrics here: usage-metrics-collector/pkg/api/samplerserverv1alpha1/doc.go Lines 38 to 48 in d82be73
CPU usage samplescgroupv1 example:
cgroupv2 example:NOTE: cpuacct subsystem: Removed in cgroupv2. Information is now rolled up under cpu.stat. (see e.g.: https://groups.google.com/g/linux.kernel/c/p9sBmjWmgxk)
Note that CPU times are now in microseconds, not in nanoseconds. In order to match units, cgroupv2 values need to be multiplied by 1000 (as 1 microsecond = 1000 nanoseconds). Summary of required changes
Documentationcgroupv1: https://www.kernel.org/doc/Documentation/cgroup-v1/cpuacct.txt Memory usage samplescgroupv1 example:
cgroupv2 example:There are many more changes in the cgroupv2 memory model and controllers vs. cpu which is mostly unchanged but reorganized.
oom_kill is unchanged but moved, total_rss is renamed to “anon”, but total memory can no longer be calculated from total_rss + total_cache + swap. We will likely need to migrate to use memory.current in some way under cgroupv2. Summary of required changes
Sidebar on the new memory metrics/statsHow can we calculate total_rss and total_cache from the new cgroupv2 memory stats? (Why did we previously collect total_cache and not e.g. memory.usage_in_bytes?) Kernel Documentation (cgroupv1):
Kernel Documentation (cgroupv2): https://docs.kernel.org/admin-guide/cgroup-v2.html#memory
(That is to say, memory.current is equivalent but not exactly the same as usage_in_bytes, whereas anon is an exact equivalent of total_rss.) Accounting weirdness
total_cache + total_rss = 8208494592 < 8329428992 ? Why do these not match? From cgroupv1 kernel documentation,
🤷 So usage_in_bytes is a little off and the sum total_rss + total_cache (+ swap) is the correct value. For cgroupv2,
The kernel documentation doesn’t have any caveats on the calculation, so this seems like the right way forward. Note: containerd uses “Memory.Usage” which is actually memory.current for both v2 and v1 |
Currently, UMC only supports collection of metrics with cgroupv1. cgroupv2 has been GA in Kubernetes since 1.25, so it would be nice to add support.
/kind feature
The text was updated successfully, but these errors were encountered: