Skip to content

cpumanager: uncorecache alignment for odd integer cpus #131850

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wongchar
Copy link
Contributor

What type of PR is this?

/kind bug
/kind cleanup

What this PR does / why we need it:

Fix for prefer-align-cpus-by-uncorecache CPUManager option that allows odd-integer cpu allocation for containers on SMT/hyperthreading enabled processors.

Which issue(s) this PR fixes:

Fixes #131610

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/4800-cpumanager-split-uncorecache

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 19, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 19, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @wongchar. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 19, 2025
@k8s-ci-robot k8s-ci-robot requested review from klueska and sjenning May 19, 2025 17:26
@ffromani
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 19, 2025
@wongchar
Copy link
Contributor Author

/retest

@wongchar
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce

@wongchar wongchar marked this pull request as ready for review May 29, 2025 20:45
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 29, 2025
@k8s-ci-robot k8s-ci-robot requested a review from Random-Liu May 29, 2025 20:45
Copy link
Contributor

@ffromani ffromani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provisional LGTM. Some minor comments about comments (no pun intended). I will need to deep dive in the test code, but test cases seems to be sufficient for the scope of the change.

sortFreeCPUs := freeCPUs.List()
// if all threads are available on each core, remove the last free cpu to satisfy cpu requirement
if len(sortFreeCPUs) > a.numCPUsNeeded {
sortFreeCPUs = sortFreeCPUs[:freeCPUs.Size()-1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, we can enter here iff the accumulator is not satisfied after taking a full uncore group, so freeCPUs.Size() can't be < 1.
This seems to be covered by tests (line 1730 in the tests file) right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct. Updated the comments, please let me know if still unclear

if a.numCPUsNeeded%2 != 0 && a.topo.CPUsPerCore() > 1 {
// sort the freeCPUs available
sortFreeCPUs := freeCPUs.List()
// if all threads are available on each core, remove the last free cpu to satisfy cpu requirement
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What could be more helpful is a short comment to describe why the last core can be dropped, replacing or augmenting the current comment

Comment on lines 567 to 568
// when SMT/hyperthread is enabled, remove the last cpu if cpu requirement is an odd integer value
// and if the number of free virtual cpus are greater than the needed cpus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments should preferably describe the why (see also line 572 below)

// when SMT/hyperthread is enabled, remove the last cpu if cpu requirement is an odd integer value
// and if the number of free virtual cpus are greater than the needed cpus
if a.numCPUsNeeded%2 != 0 && a.topo.CPUsPerCore() > 1 {
// sort the freeCPUs available
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, feel free to merge or remove these comments

@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Jun 25, 2025
@wongchar
Copy link
Contributor Author

/retest

@wongchar wongchar closed this Jun 26, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in SIG Node CI/Test Board Jun 26, 2025
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 26, 2025
@wongchar wongchar reopened this Jun 26, 2025
@github-project-automation github-project-automation bot moved this from Done to Triage in SIG Node CI/Test Board Jun 26, 2025
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 26, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wongchar
Once this PR has been reviewed and has the lgtm label, please assign derekwaynecarr for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

@wongchar: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-unit-windows-master b446e93 link false /test pull-kubernetes-unit-windows-master

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Development

Successfully merging this pull request may close these issues.

Does the cpu static policy option of PreferAlignByUncoreCache only support even CPU counts?
3 participants