Page MenuHomeFreeBSD

2/3 vfs: allow v_usecount to transition 0->1 without the interlock
ClosedPublic

Authored by mjg on Jan 15 2020, 3:01 AM.

Details

Summary

There is nothing to do but to bump the count even during said transition. There are 2 places which can do it:

  • vget only does this after locking the vnode, meaning there is no change in contract versus inactive or reclamantion
  • vref only ever did it with the interlock held which did not protect against either (that is, it would always succeed)

VCHR vnodes retain special casing due to the need to maintain dev use count.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 28675

Event Timeline

mjg created this revision.Jan 15 2020, 3:01 AM
mjg retitled this revision from vfs: allow v_usecount to transition 0->1 without the interlock to 2/3 vfs: allow v_usecount to transition 0->1 without the interlock.Jan 15 2020, 3:01 AM
jeff accepted this revision.Jan 17 2020, 11:55 PM
jeff added inline comments.
sys/kern/vfs_subr.c
2894

Do you think we should also noinline these? or is predict_false enough to prevent it?

2958

refcount_ actually will give you the old value now.

This revision is now accepted and ready to land.Jan 17 2020, 11:55 PM
mjg added inline comments.Jan 18 2020, 12:00 AM
sys/kern/vfs_subr.c
2894

It's not guaranteed to prevent inlining hence the other variant is annotated. Must have forgotten somehow skipped this one, will patch later.

2958

refcount API got abused with avoidable extensions which in part prevent adding flags to counts used by vfs. it is slowly moving towards atomic-only use. One flag for use later would be indication that inactive processing is needed plugged into usecount.

jeff added inline comments.Jan 18 2020, 12:03 AM
sys/kern/vfs_subr.c
2958

Well the rest of us didn't consider it abuse.

I would either use all refcount or none but mixing and matching is going to be problematic.

mjg added inline comments.Jan 18 2020, 12:10 AM
sys/kern/vfs_subr.c
2958

Well the rest of us didn't consider it abuse.

Pre-exisitng users don't need and it added branches they have no use for.

I would either use all refcount or none but mixing and matching is going to be problematic.

The code is increasingly moving towards pure atomics. What's missing for a complete switch is change if not zero et al which will be added later.

kib accepted this revision.Jan 18 2020, 2:56 PM
This revision was automatically updated to reflect the committed changes.