Page MenuHomeFreeBSD

vfs: release usecount using fetchadd
ClosedPublic

Authored by mjg on Wed, Sep 4, 10:00 PM.

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mjg created this revision.Wed, Sep 4, 10:00 PM
mjg edited the summary of this revision. (Show Details)Wed, Sep 4, 10:02 PM
mjg edited the summary of this revision. (Show Details)Wed, Sep 4, 10:12 PM
kib accepted this revision.Thu, Sep 5, 4:21 PM
This revision is now accepted and ready to land.Thu, Sep 5, 4:21 PM
mjg updated this revision to Diff 61907.EditedTue, Sep 10, 7:37 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.Tue, Sep 10, 7:37 PM
This revision was not accepted when it landed; it landed in state Needs Review.Fri, Sep 13, 3:49 PM
This revision was automatically updated to reflect the committed changes.