-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Blog post: New conversion from cgroup v1 CPU shares to v2 CPU weight #52793
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
base: main
Are you sure you want to change the base?
Blog post: New conversion from cgroup v1 CPU shares to v2 CPU weight #52793
Conversation
✅ Pull request preview available for checkingBuilt without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
5ad59ff to
9599c25
Compare
9599c25 to
d045e7d
Compare
|
@lmktfy I've tried to add a mathematical graph as an image. This is pretty inelegant. Do you have an idea for adding graphs in a more idiomatic way? Thanks! |
|
/test all |
|
@iholder101: No presubmit jobs available for kubernetes/website@main In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
| After a while, cgroup v1 was stared being replaced by its successor, | ||
| cgroup v2. In cgroup v2, the concept of CPU shares (which ranges from 2 to | ||
| 262144, or from 2^1 to 2^18) was replaced with CPU weight (which ranges from | ||
| 1 to 10000, or 10^10 to 10^4). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 1 to 10000, or 10^10 to 10^4). | |
| 1 to 10000, or 10^1 to 10^4). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use inline maths formulae BTW - see the pages about contributing to Kubernetes documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SergeyKanzhelev done! (it's actually 10^0 :) this is confusing).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lmktfy done.
Also, as asked in #52793 (comment), WDYT about the inlined pictures?
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Show resolved
Hide resolved
lmktfy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks; here's some early feedback. We'll try to assign a blog writing buddy soon.
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
| After a while, cgroup v1 was stared being replaced by its successor, | ||
| cgroup v2. In cgroup v2, the concept of CPU shares (which ranges from 2 to | ||
| 262144, or from 2^1 to 2^18) was replaced with CPU weight (which ranges from | ||
| 1 to 10000, or 10^10 to 10^4). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use inline maths formulae BTW - see the pages about contributing to Kubernetes documentation.
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
d045e7d to
1db2891
Compare
|
Thanks a lot everyone for your reviews! |
| This change was implemented as an OCI-level implementation. | ||
| In other words, this is not implemented Kubernetes itself, therefore the | ||
| adoption of the new conversion formula depends solely on the OCI runtime | ||
| adoption. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we vendor the library in kubernetes I believe kubernetes is affected 1.35 and above as well for pod level cpu.weight, no? @SergeyKanzhelev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think k8s is affected. But I didn't look deeper on what the effect will be and whether 1.35 will support both calculations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder where this function is used in cadvisor: google/cadvisor#3737
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, it looks like that helper is not being used. @haircommander do you see any more issues here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do use a copy of the function here https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/cm/cgroup_v2_manager_linux.go#L174
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do use a copy of the function here kubernetes/kubernetes@
master/pkg/kubelet/cm/cgroup_v2_manager_linux.go#L174
Good point!
I can make a PR to change this conversion function.
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Show resolved
Hide resolved
fbfa379 to
83e49a4
Compare
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
| requesting 1 CPU has equal priority with system processes that live outside | ||
| of Kubernetes' scope. | ||
| However, in cgroup v2, the default CPU weight is `100`, but the current | ||
| formula converts 1 CPU (1024m) to only `~39` weight - less than 40% of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean the approximately equals symbol here? We can use the real symbol, ≈.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Done
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula.md
Outdated
Show resolved
Hide resolved
f2b314d to
fa463f4
Compare
|
@lmktfy I believe all is addressed. PTAL |
Serenity611
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed for general proofreading and made some suggestions to align with the style guide, please let me know if you have any questions or concerns! :)
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Outdated
Show resolved
Hide resolved
content/en/blog/_posts/2025-10-25-new-cgroup-v1-to-v2-conversion-formula/index.md
Outdated
Show resolved
Hide resolved
SergeyKanzhelev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
approving for sig node content.
|
LGTM label has been added. Git tree hash: 33dbe84b0d2a91e51e2d10f1ffd72fcba40dca52
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: SergeyKanzhelev The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
fa463f4 to
870b38d
Compare
Signed-off-by: Itamar Holder <iholder@redhat.com>
870b38d to
40a6197
Compare
|
@Serenity611 thanks for your review! I believe all is addressed. |
|
I see that feature blog freeze is behind us. Does this have implications regarding this post? |
|
/lgtm |
|
LGTM label has been added. Git tree hash: 3514edf1a3fe6b89cf0a4500497a01b712cdbe25
|
Description
Add blog post: new cgroup v1 to v2 CPU weight conversion formula.
Document what was done in kubernetes/kubernetes#131216 with proposed quadratic formula for better CPU weight granularity and priority alignment.
Issue
Closes: #52639.