Repository navigation
Take the cpuset into account in CGroupMaxCPU - #132862
Conversation
With the static CPU manager of Kubernetes, a Guaranteed pod with an integer number of CPUs gets exclusive CPUs, and since Kubernetes 1.35 (`DisableCPUQuotaWithExclusiveCPUs`) it has no CFS quota: `cpu.max` is `max 100000`, and the limit is only visible in `cpuset.cpus.effective`. `CGroupMaxCPU` was computed only from the quota, so it was not reported for such pods, together with `CGroupUserTimeNormalized` and `CGroupSystemTimeNormalized`, which use it as the denominator. `CGroupMaxCPU` is now the minimum of the quota divided by the period and the number of CPUs in the effective cpuset (`cpuset.cpus.effective` for cgroup v2, `cpuset.effective_cpus` for cgroup v1), the same as `getNumberOfCPUCoresToUse` does. A cpuset with all online CPUs is not counted as a limit, so without any limit the metric is still not reported. `countCPUsInList` is moved out of the anonymous namespace to be reused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [73678f9] Summary: ✅
AI ReviewSummaryThe PR includes the effective cpuset in Missing context / blind spots
Findings
Tests
Final VerdictStatus: Correct the host-counter normalization and cover it with a focused regression assertion. Honor visible ancestor quotas or link a tracking issue for that limitation. Add regression coverage for the finite-quota/all-online-cpus boundary. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A container without a CPU quota and with `cpuset: "0-1"` reports `CGroupMaxCPU` = 2 and `CGroupUserTimeNormalized`, as a Kubernetes pod with exclusive CPUs under the `static` CPU manager policy, where `cpu.max` is `max`. `add_instance` gets a `cpuset` parameter, written into the docker compose file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
azat
left a comment
There was a problem hiding this comment.
Looks good, please take a look at the comments
- Open `cpuset.cpus.effective` once and keep the descriptor, as for the other files: for cgroup v2 it is reopened only when the nearest cgroup containing it changes, the cgroup v1 `cpuset.effective_cpus` is opened once. - With a finite quota, always take the minimum with the cpuset, also when the cpuset contains all online CPUs (e.g. a quota of 8 CPUs on a 4-CPU host is 4). Without a quota, a cpuset with all online CPUs is still not a limit. - Add an integration test with a quota larger than the cpuset. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units43 translation units recompiled, 248 s compile time in total, 43 of them have a recent master baseline. |
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=4 K_base=20 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
Backport #132862 to 26.11: Take the cpuset into account in `CGroupMaxCPU`
Cherry pick #132862 to 26.8: Take the cpuset into account in `CGroupMaxCPU`
Cherry pick #132862 to 26.9: Take the cpuset into account in `CGroupMaxCPU`
Cherry pick #132862 to 26.10: Take the cpuset into account in `CGroupMaxCPU`
Backport #132862 to 26.9: Take the cpuset into account in `CGroupMaxCPU`
Backport #132862 to 26.10: Take the cpuset into account in `CGroupMaxCPU`
Backport #132862 to 26.8: Take the cpuset into account in `CGroupMaxCPU`
With the
staticCPU manager policy of Kubernetes, a Guaranteed pod with an integer CPU request gets exclusive CPUs. Since Kubernetes 1.35 theDisableCPUQuotaWithExclusiveCPUsfeature gate is enabled by default, and such pods have no CFS quota:cpu.maxismax 100000, and the limit is only visible incpuset.cpus.effective.CGroupMaxCPUwas computed only from the quota, so it disappeared for these pods.CGroupUserTimeNormalizedandCGroupSystemTimeNormalizeddisappeared with it, because they use it as the denominator, and theOS*Normalizedmetrics fell back to the number of CPUs of the host.CGroupMaxCPUis now the minimum of the quota divided by the period and the number of CPUs in the effective cpuset: the nearestcpuset.cpus.effectivefor cgroup v2,cpuset/cpuset.effective_cpusfor cgroup v1. This is whatgetNumberOfCPUCoresToUsealready does (it is not changed). The quota code path is not changed either. The cpuset is re-read on every update, because kubelet changes the cpuset of shared-pool pods as pods with exclusive CPUs come and go.countCPUsInListis moved out of the anonymous namespace to be reused.A cpuset that contains all online CPUs is not a limit, so without any limit the metric is still not reported, as before. The only other case where the value changes is when there is both a quota and a smaller cpuset (e.g.
docker run --cpus=8 --cpuset-cpus=0-3, or a shared-pool pod on astaticCPU manager node whose limit is larger than the shared pool). ThereCGroupMaxCPUis now 4 instead of 8, which is what the process can actually use.No test is added: the cgroup paths are fixed (
/sys/fs/cgroup), and a stateless test cannot fake them.Related: #128621
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
CGroupMaxCPUasynchronous metric now takes the effective cpuset of the cgroup into account, as the minimum of the CPU quota and the number of CPUs in the cpuset. Previously it was not reported for containers with exclusive CPUs and no CFS quota, such as Kubernetes pods with thestaticCPU manager policy (wherecpu.maxismaxsince Kubernetes 1.35), andCGroupUserTimeNormalizedandCGroupSystemTimeNormalizedwere missing as well.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/132862]
Version info
26.12.1.351-master(included in26.12and later)26.11.1.2938,26.10.13.6,26.9.39.6,26.8.47.3