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
F105305862: D34850.diff
Sat, Dec 14, 5:38 PM
Unknown Object (File)
Wed, Dec 4, 3:36 PM
Unknown Object (File)
Sun, Nov 24, 6:13 PM
Unknown Object (File)
Sun, Nov 24, 1:14 AM
Unknown Object (File)
Wed, Nov 20, 1:16 PM
Unknown Object (File)
Fri, Nov 15, 11:46 AM
Unknown Object (File)
Nov 13 2024, 4:44 PM
Unknown Object (File)
Nov 13 2024, 2:56 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