[PATCH] Finish the task 'Convert mountlist_mtx to rwlock'

Davide Italiano davide at freebsd.org
Thu Mar 12 04:14:52 UTC 2015


On Wed, Mar 11, 2015 at 9:06 PM, Ryan Stone <rysto32 at gmail.com> wrote:
> On Wed, Mar 11, 2015 at 9:10 AM, Tiwei Bie <btw at mail.ustc.edu.cn> wrote:
>> Hi, Mateusz!
>>
>> I have finished the task: Convert mountlist_mtx to rwlock [1].
>
> My first comment is, are we sure that we actually want an rwlock here
> instead of an rmlock?  An rmlock will offer much better performance in
> workloads that mostly only take read locks, and rmlocks do not suffer
> the priority inversion problems that rwlocks do.  From the description
> on the wiki page, it sounds like an rmlock would be ideal here:
>

Snippet:
[...]
-                       mtx_unlock(&mountlist_mtx);
+                       rw_runlock(&mountlist_lock);
                mp->mnt_kern_flag |= MNTK_MWAIT;
                msleep(mp, MNT_MTX(mp), PVFS | PDROP, "vfs_busy", 0);
                if (flags & MBF_MNTLSTLOCK)
-                       mtx_lock(&mountlist_mtx);
+                       rw_rlock(&mountlist_lock);
[...]

My understanding is that readers are not allowed to sleep while
holding an rmlock() so a drop-in replacement don't work in this case.

-- 
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare


More information about the freebsd-hackers mailing list