Page MenuHomeFreeBSD

Use an rmlock to lock vfs cache
Needs ReviewPublic

Authored by rstone on Mar 12 2015, 2:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 28, 9:10 PM
Unknown Object (File)
Wed, Nov 27, 12:08 PM
Unknown Object (File)
Nov 17 2024, 5:06 AM
Unknown Object (File)
Nov 12 2024, 8:49 PM
Unknown Object (File)
Nov 11 2024, 6:50 AM
Unknown Object (File)
Nov 4 2024, 8:39 PM
Unknown Object (File)
Nov 4 2024, 5:44 PM
Unknown Object (File)
Oct 26 2024, 3:26 PM
Subscribers
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

Switch the VFS cache to use an rmlock for locking. In a simple
test using buildworld/buildkernel on a 12-core Haswell Xeon system,
this lead to approximately a 10% performance increase:

x orig.log
+ rmlock.log
+------------------------------------------------------------------------------+

+ x
++++ x x xxx
A_________A___M____

+------------------------------------------------------------------------------+

N           Min           Max        Median           Avg        Stddev

x 6 2710.31 2821.35 2816.75 2798.0617 43.324817
+ 5 2488.25 2500.25 2498.04 2495.756 5.0494782
Difference at 95.0% confidence

-302.306 +/- 44.4709
-10.8041% +/- 1.58935%
(Student's t, pooled s = 32.4674)

More importantly is a correctness issue: I recently hit a case on an
single core VM that was overloaded by user priority threads consuming
the CPU. A real-time priority process got blocked waiting to acquire
a write lock on the VFS cache and was starved for over 30 seconds
because of a priority inversion problem where a reader held the VFS
cache lock but was preempted by the CPU hogs. The rmlock is able to
propagate priority even to readers and therefore avoids the problem.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

rstone retitled this revision from to Use an rmlock to lock vfs cache.
rstone edited the test plan for this revision. (Show Details)
rstone updated this object.

Do we still want to do this?

No. Locking was significantly revamped and the problem at hand us unlikely to be encountered. Should it be encountered, the new (much finer-grained) locking can be modified to use exclusive-only locks. The speed up as reported here was disputed on the mailing lists and was likely not present.

So the namecache now only uses SMR and mutexes, no read-write locks anywhere. This should be whacked.