Page MenuHomeFreeBSD

rmlock: Add required compiler barriers to _rm_runlock()
ClosedPublic

Authored by markj on Feb 25 2022, 9:10 PM.
Tags
None
Referenced Files
F148372139: D34381.id103244.diff
Tue, Mar 17, 10:38 AM
Unknown Object (File)
Mon, Mar 16, 12:28 AM
Unknown Object (File)
Mon, Mar 16, 12:22 AM
Unknown Object (File)
Fri, Mar 13, 6:11 AM
Unknown Object (File)
Fri, Mar 13, 5:52 AM
Unknown Object (File)
Fri, Mar 13, 5:52 AM
Unknown Object (File)
Thu, Mar 12, 5:09 PM
Unknown Object (File)
Thu, Mar 12, 10:37 AM
Subscribers

Details

Summary

Also remove excessive whitespace in _rm_rlock().

Diff Detail

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

Event Timeline

markj requested review of this revision.Feb 25 2022, 9:10 PM
This revision is now accepted and ready to land.Feb 25 2022, 9:29 PM
sys/kern/kern_rmlock.c
516

Why not just use critical_enter()/critical_exit() here? Are we in a spot where the pending preemption check in critical_exit() can't be tolerated?

sys/kern/kern_rmlock.c
516

See the if statement below, preemption check is merged with another one to save a branch.

sys/kern/kern_rmlock.c
516

Another reason is that critical_enter()/_exit() were historically not inline functions; that changed only in the past few years. So we could certainly use critical_enter() here, but switching to critical_exit() in _rm_rlock() results in worse-looking code: https://reviews.freebsd.org/P540
In particular, the patched version uses many callee-saved registers.

I suspect it's worth keeping this micro-optimization. I guess we could at least use critical_enter(), but that on its own doesn't represent much of an improvement to me.

sys/kern/kern_rmlock.c
516

I have to note critical_exit is already suboptimal by having to test for preemption using a different variable. Instead, both preemption and the flag could be in one int (if not short). It does not even have to be per-thread, rather can be moved per-CPU. I don't know how feasible it is outside of amd64 though.