Page MenuHomeFreeBSD

lockmgr: add adaptive spinning
ClosedPublic

Authored by mjg on Jul 21 2020, 3:18 PM.
Tags
None
Referenced Files
F81914444: D25753.diff
Tue, Apr 23, 2:32 AM
Unknown Object (File)
Tue, Apr 16, 7:11 PM
Unknown Object (File)
Thu, Apr 11, 11:38 AM
Unknown Object (File)
Thu, Mar 28, 10:26 AM
Unknown Object (File)
Jan 14 2024, 10:51 AM
Unknown Object (File)
Nov 23 2023, 11:55 PM
Unknown Object (File)
Nov 9 2023, 9:40 AM
Unknown Object (File)
Oct 3 2023, 1:06 PM
Subscribers

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 - subversion
Lint
Lint Not Applicable
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.