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

Mark Johnston markj at FreeBSD.org
Thu Mar 12 04:44:43 UTC 2015


On Wed, Mar 11, 2015 at 09:14:49PM -0700, Davide Italiano wrote:
> 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.

That's true of an rwlock as well though. And the mountlist lock is
dropped around the msleep call in this snippet.


More information about the freebsd-hackers mailing list