Page MenuHomeFreeBSD

linux(4); Adopt affinity syscalls to the recent kernel changes.
AbandonedPublic

Authored by dchagin on Apr 8 2022, 8:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 1, 2:08 AM
Unknown Object (File)
Sun, Apr 21, 8:47 PM
Unknown Object (File)
Sat, Apr 20, 7:09 PM
Unknown Object (File)
Sun, Apr 14, 8:39 PM
Unknown Object (File)
Sun, Apr 14, 8:22 PM
Unknown Object (File)
Sun, Apr 14, 7:56 PM
Unknown Object (File)
Sun, Apr 14, 7:26 PM
Unknown Object (File)
Mar 7 2024, 11:41 PM
Subscribers

Details

Reviewers
kib
jhb
Group Reviewers
Linux Emulation
Summary

Also cache thread tid to avoid ref to an unlocked thread.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 45386
Build 42274: arc lint + arc unit

Event Timeline

Note that FreeBSD would benefit from similar changes in the native API btw. As it was we can't safely raise MAXCPU in the default amd64 kernel (for example) because it breaks the ABI since old kernels would be too pick about userland having a larger size. It would be good perhaps to fix the native syscalls to adopt Linux's more flexible semantics and then you would not need to change the Linux ABI itself.

dchagin retitled this revision from linux(4); Fix affinity syscalls. to linux(4); Adopt affinity syscalls to the recent kernel changes..Apr 20 2022, 4:07 PM
dchagin edited the summary of this revision. (Show Details)
In D34850#790822, @jhb wrote:

Note that FreeBSD would benefit from similar changes in the native API btw. As it was we can't safely raise MAXCPU in the default amd64 kernel (for example) because it breaks the ABI since old kernels would be too pick about userland having a larger size. It would be good perhaps to fix the native syscalls to adopt Linux's more flexible semantics and then you would not need to change the Linux ABI itself.

There are e.g. sched_setaffinity(3) and cpuset_setaffinity(2). First is 'linux-ish' and is currently implemented as libc wrapper, while second is the native syscall. I do not object against moving FreeBSD native primitive to be more linux-like, but this is quite hard to do, I will try to explain.

I added very naive sched_get/setaffinity(3) libc wrappers only to improve the source-level compatibility with Linux, after spending a lot of time at least twice converting ucx (this is some wrapper/foundation for transport for openmpi and like) and then tcmalloc. The result was exactly opposite, it makes a lot of software packages note glibc-like API and depending on every small nit in the behavior. You might remember the CPUSET(3) saga, and also look at the git log for lib/libc/gen/sched_*affinity.c.

There is probably less code that would try to exercise such knowledge for cpuset_* API, but who knows.

From your changes, I see at least one more compat shim we probably should add, D35045

fixed after latest kernel changes D34849

Linux ignores high bits, removed during testing

Merged into one revision with D34849