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 cpuset_getaffinity instead of sysconf(_SC_NPROCESSORS_ONLN) #16173

Open
asomers opened this issue May 7, 2024 · 0 comments
Open

Use cpuset_getaffinity instead of sysconf(_SC_NPROCESSORS_ONLN) #16173

asomers opened this issue May 7, 2024 · 0 comments
Labels
Type: Feature Feature request or new feature

Comments

@asomers
Copy link
Contributor

asomers commented May 7, 2024

Describe the feature would like to see added to OpenZFS

Several functions in libzfs and the zfs commands construct thread pools sized according to the number of CPUs in the system. They determine that via the sysconf(_SC_NPROCESSORS_ONLN) function. But that reports that total number of CPUs in the system. It would be more appropriate to use the number of CPUs available to the currrent process instead. That can be determined via cpuset_getaffinity on FreeBSD or sched_getaffinity on Linux.

How will this feature improve OpenZFS?

It will prevent thread pools from being oversized wherever the system administrator has configured cpusets.

Additional context

https://man.freebsd.org/cgi/man.cgi?query=cpuset_getaffinity&sektion=2&n=1
https://linux.die.net/man/2/sched_getaffinity
https://github.com/freebsd/freebsd-src/blob/0612538e3ac93c1884f595a72609c078aefbcc28/bin/nproc/nproc.c#L118

@asomers asomers added the Type: Feature Feature request or new feature label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Feature request or new feature
Projects
None yet
Development

No branches or pull requests

1 participant