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)
Tue, Nov 12, 8:49 PM
Unknown Object (File)
Mon, Nov 11, 6:50 AM
Unknown Object (File)
Mon, Nov 4, 8:39 PM
Unknown Object (File)
Mon, Nov 4, 5:44 PM
Unknown Object (File)
Sat, Oct 26, 3:26 PM
Unknown Object (File)
Oct 16 2024, 3:45 AM
Unknown Object (File)
Sep 30 2024, 6:23 AM
Unknown Object (File)
Sep 28 2024, 1:37 AM
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.