Page MenuHomeFreeBSD

vfs: provide new locking primitives which elide ->v_vnlock and shared locking disablement
ClosedPublic

Authored by mjg on Dec 4 2019, 3:18 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 26, 3:01 AM
Unknown Object (File)
Fri, Apr 26, 3:00 AM
Unknown Object (File)
Fri, Apr 26, 3:00 AM
Unknown Object (File)
Fri, Apr 26, 3:00 AM
Unknown Object (File)
Thu, Apr 25, 8:57 PM
Unknown Object (File)
Sat, Mar 30, 8:19 AM
Unknown Object (File)
Mar 7 2024, 11:58 AM
Unknown Object (File)
Dec 20 2023, 6:51 AM
Subscribers

Details

Summary

Both of these features are not needed by many consumers and result in avoidable reads which in turn puts them on profiles due to cache-line ping ponging.

On top of that the current lockgmr entry point is slower than necessary single-threaded. As an attempted clean up preparing for other changes, provide new routines which don't support any of the aforementioned features.

With these patches in place vop_stdlock and vop_stdunlock disappear from flamegraphs during -j 104 buildkernel.

I don't have a strong opinion about naming of vop_ routines. Part of longer term idea is to provide explicit VOP_XLOCK and VOP_SLOCK routines so that the code does not have to branch on the request. Filesystems which don't support shared locking can just set both to the same routine. Finally, if the code followed that it e.g., VOP_SLOCKed, it can VOP_SUNLOCK. In the current state it wont make a difference, but it will open up possiblity of doing lock xadd on the lock word without reading from it earlier (and in turn increase scalability). Once more filesystems which don't support shared locking can set this to the same routine which would be used for VOP_XUNLOCK.

Test Plan

will ask pho

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 27931

Event Timeline

mjg edited the summary of this revision. (Show Details)

You need to add comments to lockmgr about when these functions are appropriate to use and why. It will not be immediately clear to someone who comes after you.

sys/kern/vfs_default.c
574

Not sure we need this assert in both places. lockmgr is probably sufficient.

  • remove shared lock assertion from vop_stdlock
  • add a comment about new lockmgr primitives
  • convert zfs. both tmpfs and zfs changes will be committed separately
mjg marked an inline comment as done.Dec 7 2019, 1:33 AM

The patch was tested by pho, no issues.

jeff added inline comments.
sys/kern/kern_lock.c
1162–1164

If it is only these features which are not supported can you rewrite this slightly? Simply say,

The following lockmgr features are unsupported; shared lock disable, error after sleep, unlocking the interlock.

You might actually do better to specify LK_NOSHARE, LK_INTERLOCK, and LK_SLEEPFAIL are unsupported.

This revision is now accepted and ready to land.Dec 11 2019, 10:03 PM