Skip to content

cpuset: add NumCPU to read the host's online CPU count from sysfs#354

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes:masterfrom
dims:cpuset-numcpu
Jun 26, 2026
Merged

cpuset: add NumCPU to read the host's online CPU count from sysfs#354
kubernetes-prow[bot] merged 1 commit into
kubernetes:masterfrom
dims:cpuset-numcpu

Conversation

@dims

@dims dims commented Jun 26, 2026

Copy link
Copy Markdown
Member

NumCPU reads /sys/devices/system/cpu/online and returns the number of online CPUs. Unlike runtime.NumCPU it is not affected by the calling process's CPU affinity (its cgroup cpuset), so it reflects the whole machine, which is what callers want when sizing a host-wide resource by CPU count.

What type of PR is this?

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:
Based on reviewer request from kubernetes/kubernetes#140021

Release note:

Add a new "NumCPU" method that returns the number of CPUs that are online

NumCPU reads /sys/devices/system/cpu/online and returns the number of online
CPUs. Unlike runtime.NumCPU it is not affected by the calling process's CPU
affinity (its cgroup cpuset), so it reflects the whole machine, which is what
callers want when sizing a host-wide resource by CPU count.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
@kubernetes-prow kubernetes-prow Bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 26, 2026
@kubernetes-prow kubernetes-prow Bot requested review from aojea and thockin June 26, 2026 01:15
@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 26, 2026
@dims

dims commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

/assign @danwinship

@sbueringer

Copy link
Copy Markdown
Member

Thx!

/lgtm

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 26, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dims, sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@kubernetes-prow kubernetes-prow Bot merged commit be93311 into kubernetes:master Jun 26, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants