git: 62801712dfc1 - main - libthr: Fix pthread_[g|s]etaffinity_np manual.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 29 Jan 2023 12:38:21 UTC
The branch main has been updated by dchagin:
URL: https://cgit.FreeBSD.org/src/commit/?id=62801712dfc17fed6f8d4c9b64dca18d51a2bf9b
commit 62801712dfc17fed6f8d4c9b64dca18d51a2bf9b
Author: Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-01-29 12:36:25 +0000
Commit: Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-01-29 12:36:25 +0000
libthr: Fix pthread_[g|s]etaffinity_np manual.
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.
Reviewed by: jhb, kib
Differential Revision: https://reviews.freebsd.org/D38111
MFC after: 1 week
---
share/man/man3/pthread_affinity_np.3 | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/share/man/man3/pthread_affinity_np.3 b/share/man/man3/pthread_affinity_np.3
index 0a52add2ee3c..b36e5772c1e3 100644
--- a/share/man/man3/pthread_affinity_np.3
+++ b/share/man/man3/pthread_affinity_np.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 12, 2021
+.Dd January 29, 2023
.Dt PTHREAD_AFFINITY_NP 3
.Os
.Sh NAME
@@ -50,14 +50,19 @@ Masks of type
are composed using the
.Dv CPU_SET
macros.
-The kernel tolerates large sets as long as all CPUs specified
-in the set exist.
-Sets smaller than the kernel uses generate an error on calls to
+If the user-supplied mask is not large enough to fit all of the matching CPUs,
.Fn pthread_getaffinity_np
-even if the result set would fit within the user supplied set.
+fails with
+.Er ERANGE .
Calls to
.Fn pthread_setaffinity_np
-tolerate small sets with no restrictions.
+tolerate masks of any size with no restrictions.
+The kernel uses the meaningful part of the mask, where the upper bound is
+the maximum CPU id present in the system.
+If bits for non-existing CPUs are set, calls to
+.Fn pthread_setaffinity_np
+fails with
+.Er EINVAL .
.Pp
The supplied mask should have a size of
.Fa cpusetsize
@@ -96,6 +101,12 @@ and
.Fn pthread_setaffinity_np
functions may fail if:
.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa cpusetp
+argument specified when calling
+.Fn pthread_setaffinity_np
+was not a valid value.
.It Bq Er EDEADLK
The
.Fn pthread_setaffinity_np
@@ -112,7 +123,7 @@ argument could not be found.
.It Bq Er ERANGE
The
.Fa cpusetsize
-was either preposterously large or smaller than the kernel set size.
+was smaller than needed to fit all of the matching CPUs.
.It Bq Er EPERM
The calling thread did not have the credentials required to complete the
operation.