Page MenuHomeFreeBSD

[wip] vfs: decentralize device usecount
AbandonedPublic

Authored by mjg on Sep 4 2019, 8:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 13, 8:30 AM
Unknown Object (File)
Thu, Mar 28, 9:41 PM
Unknown Object (File)
Jan 30 2024, 10:55 PM
Unknown Object (File)
Dec 22 2023, 9:58 PM
Unknown Object (File)
Oct 11 2023, 9:15 AM
Unknown Object (File)
Sep 13 2023, 8:47 PM
Unknown Object (File)
Aug 25 2023, 1:23 AM
Unknown Object (File)
Aug 14 2023, 3:42 PM
Subscribers

Details

Reviewers
kib
jeff
Summary

Currently VCHR vnodes are special-cased during each v_usecount bump in order to maintain the counter in the device. This causes an avoidable slowdown since ->v_type shares the cacheline with the count. It can be moved far enough to be less of a problem, but constant special casing would remain.

Proposed solution is simple in nature: keep an array of all vnodes associated with the device and if necessary walk it to get the total usecount.

Of course many devfs mount points can result in many vnodes using the same device, which poses a problem with possibly long walks. It is solved in two ways:

  • vnodes are almost never just held, they are either fully activated or on the free list. thus vdrop and vhold move the vnode in an out of the array as needed, effectively only keeping used vnodes in there
  • the exact count is almost never needed. instead callers mostly want to know if it is any of 0, 1 or 2. count_dev_cmp is introduced to terminate the walk as soon as it knows the result

The code is still a prototype and has rather verbose names. I used a version which maintained both the centralized count and the new one, with the counting routine comparing both. No mismatches were found during some time of poudriere (both counts were only modified under dev_lock to maintain consistency)

Note the v_rdev assignment, table manipulations and counting are all protected with dev_lock.

Also the exact value of the count is similarly racy to the original - previously an update could have been stalled on the dev_lock while the counter was being read.

Diff Detail

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