Page MenuHomeFreeBSD

lockmgr: add adaptive spinning
ClosedPublic

Authored by mjg on Jul 21 2020, 3:18 PM.

Details

Summary

It is very conservative. Only spinning when LK_ADAPTIVE is passed, only on exclusive lock and never when any waiters are present. buffer cache is remains not spinning.

This reduces total sleep times during buildworld etc., but it does not help there (vm contention is the culprit along with slock + upgrade which is not covered).

For microbenchmarks: open3_processes -t 52 (open/close of the same file for writing) ops/s
before: 258845
after: 801638

Test Plan

tested by pho

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mjg requested review of this revision.Jul 21 2020, 3:18 PM
mjg created this revision.
mjg edited the summary of this revision. (Show Details)
sys/kern/kern_lock.c
1048 ↗(On Diff #74745)

This change is unrelated ?

1234 ↗(On Diff #74745)

And this.

sys/ufs/ffs/ffs_vnops.c
448 ↗(On Diff #74745)

Why you enforce LK_ADAPTIVE inside lockmgr_xlock/slock, while for lockmgr_lock_flags() only do that for UFS ?

sys/kern/kern_lock.c
1048 ↗(On Diff #74745)

with the patch lockmgr_slock_try stops reading on its own

sys/ufs/ffs/ffs_vnops.c
448 ↗(On Diff #74745)

lockmgr_lock_flags is fully compatible with original lockmgr entry point in terms of semantics and I did not want to change that. In particular it may be feasible to convert bufcache to use it instead of the current __lockmgr entry point (which should be refactored away). that said, i don't have a strong opinion on this one.

This revision is now accepted and ready to land.Jul 21 2020, 8:23 PM
This revision was automatically updated to reflect the committed changes.