]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
cpuset: Fix sched_[g|s]etaffinity() for better compatibility with Linux.
authorDmitry Chagin <dchagin@FreeBSD.org>
Sun, 29 Jan 2023 13:17:33 +0000 (16:17 +0300)
committerDmitry Chagin <dchagin@FreeBSD.org>
Mon, 6 Feb 2023 19:06:31 +0000 (22:06 +0300)
commit69e8cea385db64f86ccd3e9a2ab6ff61c5976f64
treefb31fde897e3f958f045a90fc455401b12d54ede
parent0c21dc519c838326c90e8b3bbdcc0ad0abf50614
cpuset: Fix sched_[g|s]etaffinity() for better compatibility with Linux.

Under Linux to sched_[g|s]etaffinity() functions the value returned from a call
to gettid(2) (thread id) can be passed in the argument pid. Specifying pid as 0
will set the attribute for the calling thread, and passing the value returned
from a call to getpid(2) (process id) will set the attribute for the main thread
of the thread group.

Native cpuset(2) family of system calls has "which" argument to determine how
the value of id argument is interpreted, i.e., CPU_WHICH_TID is used to pass
a thread id and CPU_WHICH_PID - to pass a process id.

For now native sched_[g|s]etaffinity() implementation is wrong as uses "which"
CPU_WHICH_PID to pass both (process and thread id) to the kernel. To fix this
adding a new "which" CPU_WHICH_TIDPID intended to handle both id's.

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

(cherry picked from commit c21b080f3dc2f5e91ada608d4385b7ed6538ba9b)
lib/libc/gen/sched_getaffinity.c
lib/libc/gen/sched_setaffinity.c
lib/libc/sys/cpuset.2
sys/kern/kern_cpuset.c
sys/sys/cpuset.h