mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 02:20:59 +03:00
0e4c830bc1
In our codebase, `cond_resched() and `schedule()` are Linux kernel functions that have replaced the OpenSolaris `kpreempt()` functions in the codebase to such an extent that `kpreempt()` in zfs_context.h was broken. Nobody noticed because we did not actually use it. The header had defined `kpreempt()` as `yield()`, which works on OpenSolaris and Illumos where `sched_yield()` is a wrapper for `yield()`, but that does not work on any other platform. The FreeBSD platform specific code implemented shims for these, but the shim for `schedule()` forced us to wait, which is different than merely rescheduling to another thread as the original Linux code does, while the shim for `cond_resched()` had the same definition as its kernel kpreempt() shim. After studying this, I have concluded that we should reintroduce the kpreempt() function in platform independent code with the following definitions: - In the Linux kernel: kpreempt(unused) -> cond_resched() - In the FreeBSD kernel: kpreempt(unused) -> kern_yield(PRI_USER) - In userspace: kpreempt(unused) -> sched_yield() In userspace, nothing changes from this cleanup. In the kernels, the function `fm_fini()` will now call `kern_yield(PRI_USER)` on FreeBSD and `cond_resched()` on Linux. This is instead of `pause("schedule", 1)` on FreeBSD and `schedule()` on Linux. This makes our behavior consistent across platforms. Note that Linux's SPL continues to use `cond_resched()` and `schedule()`. However, those functions have been removed from both the FreeBSD code and userspace code. This should have the benefit of making it slightly easier to port the code to new platforms by making how things should be mapped less confusing. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Neal Gompa <ngompa@datto.com> Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Closes #13845 |
||
---|---|---|
.. | ||
acl.h | ||
atomic.h | ||
byteorder.h | ||
callb.h | ||
callo.h | ||
cmn_err.h | ||
condvar.h | ||
cred.h | ||
ctype.h | ||
debug.h | ||
disp.h | ||
dkio.h | ||
errno.h | ||
fcntl.h | ||
file.h | ||
inttypes.h | ||
isa_defs.h | ||
kmem_cache.h | ||
kmem.h | ||
kstat.h | ||
list.h | ||
mod_os.h | ||
mutex.h | ||
param.h | ||
proc.h | ||
processor.h | ||
procfs_list.h | ||
random.h | ||
rwlock.h | ||
shrinker.h | ||
sid.h | ||
signal.h | ||
simd.h | ||
stat.h | ||
string.h | ||
sunddi.h | ||
sysmacros.h | ||
systeminfo.h | ||
taskq.h | ||
thread.h | ||
time.h | ||
timer.h | ||
trace_spl.h | ||
trace_taskq.h | ||
trace.h | ||
tsd.h | ||
types32.h | ||
types.h | ||
uio.h | ||
user.h | ||
vfs.h | ||
vmem.h | ||
vmsystm.h | ||
vnode.h | ||
wait.h | ||
wmsum.h | ||
zmod.h | ||
zone.h |