Skip to content

Use sched_getaffinity syscall to get online CPUs on Linux#20

Merged
tklauser merged 1 commit intomasterfrom
online-cpus-sched-getaffinity
Aug 17, 2021
Merged

Use sched_getaffinity syscall to get online CPUs on Linux#20
tklauser merged 1 commit intomasterfrom
online-cpus-sched-getaffinity

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.

1 participant