HomeFreeBSD

cpuset: Fix sched_[g|s]etaffinity() for better compatibility with Linux.

Description

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)

Details

Provenance
dchaginAuthored on Jan 29 2023, 1:17 PM
Reviewer
kib
Differential Revision
D38209: cpuset: Fix sched_[g|s]etaffinity() for better compatibility with Linux.
Parents
rG0c21dc519c83: libthr: Trim trailing whitespaces in pthread_attr_affinity.
Branches
Unknown
Tags
Unknown