Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Mar 2015 00:06:02 -0400
From:      Ryan Stone <rysto32@gmail.com>
To:        Tiwei Bie <btw@mail.ustc.edu.cn>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>, mjguzik@gmail.com, wca@freebsd.org
Subject:   Re: [PATCH] Finish the task 'Convert mountlist_mtx to rwlock'
Message-ID:  <CAFMmRNyLJgLuk-VPSuyBCpO1bkdmyGf3s89X-An1vCCMwn=B=A@mail.gmail.com>
In-Reply-To: <1426079434-51568-1-git-send-email-btw@mail.ustc.edu.cn>
References:  <1426079434-51568-1-git-send-email-btw@mail.ustc.edu.cn>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 11, 2015 at 9:10 AM, Tiwei Bie <btw@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:

> Interested person can upgrade this task to non-junior by coming up with a
> solution exploiting rare need to modify the list. Example approaches include
> designing a locking primitive with cheap shared locking (think: per-cpu) at
> the expense of exclusive locking.

The rmlock primitive does exactly this optimization.  See the manpage
for the API (it's mostly very similar to the rwlock API):
https://www.freebsd.org/cgi/man.cgi?query=rmlock&apropos=0&sektion=0&manpath=FreeBSD+10.1-RELEASE&arch=default&format=html


> void   zfs_mountlist_wlock(void);
> void   zfs_mountlist_wunlock(void);
> void   zfs_mountlist_rlock(void);
> void   zfs_mountlist_runlock(void);

Why not:

#define zfs_mountlist_wlock() _zfs_mountlist_wlock(__FILE__, __LINE__)
void _zfs_mountlist_wlock(const char *file, int line);

/* etc, etc */

(This may be moot if we switch to an rmlock though)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFMmRNyLJgLuk-VPSuyBCpO1bkdmyGf3s89X-An1vCCMwn=B=A>