Page MenuHomeFreeBSD

lockmgr: add adaptive spinning

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



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

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
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)
1048 ↗(On Diff #74745)

This change is unrelated ?

1234 ↗(On Diff #74745)

And this.

448 ↗(On Diff #74745)

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

1048 ↗(On Diff #74745)

with the patch lockmgr_slock_try stops reading on its own

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.