Page MenuHomeFreeBSD

lockmgr: add adaptive spinning
ClosedPublic

Authored by mjg on Jul 21 2020, 3:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 28, 12:50 PM
Unknown Object (File)
Oct 4 2024, 7:14 PM
Unknown Object (File)
Oct 4 2024, 11:56 AM
Unknown Object (File)
Oct 3 2024, 9:54 PM
Unknown Object (File)
Oct 1 2024, 4:13 PM
Unknown Object (File)
Sep 27 2024, 10:26 PM
Unknown Object (File)
Sep 25 2024, 7:48 PM
Unknown Object (File)
Sep 22 2024, 2:13 AM
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.