Page MenuHomeFreeBSD

vfs: release usecount using fetchadd
ClosedPublic

Authored by mjg on Sep 4 2019, 10:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 13, 7:42 AM
Unknown Object (File)
Mon, Apr 1, 2:45 PM
Unknown Object (File)
Feb 29 2024, 7:29 PM
Unknown Object (File)
Dec 23 2023, 3:41 AM
Unknown Object (File)
Nov 11 2023, 6:07 AM
Unknown Object (File)
Nov 7 2023, 4:42 AM
Unknown Object (File)
Nov 7 2023, 12:18 AM
Unknown Object (File)
Oct 10 2023, 5:07 AM
Subscribers

Details

Summary

If we release the last usecount we take ownership of the hold count, which means the vnode will remain allocated until we vdrop it. If someone else vrefs they will find no usecount and will proceed to add their own hold count. These 2 facts mean we can fetchadd instead of having a cmpset loop.

In a trivial microbenchmark on tmpfs doing stat on different files with full path lookup to /tmp/file* with 104 threads this gives me a bump from ~178k ops/s to ~213k ops/s. Note that a mere benchmark of the sort instantly runs into contention on the vnode list due to constant movement between active and free list. I circumvented that by tail -f tmp/* which activated all leaf vnodes. This problem will be addressed elsewhere.

Diff was generated on top of D21525 for simplicity, but the idea does not depend on it and I can write it against stock -current. None of the code acting on usecount of 0 seems to mind the value transitioning from not-0 to 0 while the interlock is held.

Test Plan

Already tested by pho

Diff Detail

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

Event Timeline

This revision is now accepted and ready to land.Sep 5 2019, 4:21 PM
mjg edited the test plan for this revision. (Show Details)
  • rework on top of stock head to remove the dependency on devfs patch
  • .. the type var should probably move and will be in a separate review

The patch was tested by pho.

This revision now requires review to proceed.Sep 10 2019, 7:37 PM
This revision was not accepted when it landed; it landed in state Needs Review.Sep 13 2019, 3:49 PM
This revision was automatically updated to reflect the committed changes.