]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
libthr: Fix pthread_attr_[g|s]etaffinity_np to match it's manual and the kernel.
authorDmitry Chagin <dchagin@FreeBSD.org>
Sun, 29 Jan 2023 12:35:18 +0000 (15:35 +0300)
committerDmitry Chagin <dchagin@FreeBSD.org>
Mon, 6 Feb 2023 19:06:30 +0000 (22:06 +0300)
commitbdb06df5ca6e44af87b5246771c77e6b851b6f71
treebc6e3953bc780460015e7201238618ad3c893c01
parent669dc70e40ff68e6d58df84ce21c175fe6c6321f
libthr: Fix pthread_attr_[g|s]etaffinity_np to match it's manual and the kernel.

Since f35093f8 semantics of a thread affinity functions is changed to be a
compatible with Linux:

In case of getaffinity(), the minimum cpuset_t size that the kernel permits is
the maximum CPU id, present in the system, / NBBY bytes, the maximum size is not
limited.
In case of setaffinity(), the kernel does not limit the size of the user-provided
cpuset_t, internally using only the meaningful part of the set, where the upper
bound is the maximum CPU id, present in the system, no larger than the size of
the kernel cpuset_t.

To match pthread_attr_[g|s]etaffinity_np checks of the user-provided cpusets to
the kernel behavior export the minimum cpuset_t size allowed by running kernel
via new sysctl kern.sched.cpusetsizemin and use it in checks.

Reviewed by:
Differential Revision: https://reviews.freebsd.org/D38112
MFC after: 1 week

(cherry picked from commit 01f74ccd5a0d1a444703e931339709c7de5296b5)
lib/libthr/thread/thr_attr.c
sys/kern/kern_cpuset.c
sys/kern/subr_smp.c
sys/sys/cpuset.h