Skip to content
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

Use sched_getaffinity syscall to get online CPUs on Linux #20

Merged
merged 1 commit into from
Aug 17, 2021

Conversation

tklauser
Copy link
Owner

The sched_getaffinity syscall returns the mask of online CPUs, so prefer
that over reading sysfs files on Linux. Only if the syscall returns an
errors, fall back to the existing method.

Running strace getconf _NPROCESSORS_ONLN this also seems to be the
method glibc's getconf uses.

The sched_getaffinity syscall returns the mask of online CPUs, so prefer
that over reading sysfs files on Linux. Only if the syscall returns an
errors, fall back to the existing method.

Running `strace getconf _NPROCESSORS_ONLN` this also seems to be the
method glibc's `getconf` uses.
@tklauser tklauser merged commit ce6ed4c into master Aug 17, 2021
@tklauser tklauser deleted the online-cpus-sched-getaffinity branch August 17, 2021 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant