From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 12 04:06:03 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C0B3982C for ; Thu, 12 Mar 2015 04:06:03 +0000 (UTC) Received: from mail-ie0-x231.google.com (mail-ie0-x231.google.com [IPv6:2607:f8b0:4001:c03::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 84C93EDE for ; Thu, 12 Mar 2015 04:06:03 +0000 (UTC) Received: by iecvj10 with SMTP id vj10so13797383iec.0; Wed, 11 Mar 2015 21:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=lZxNjJRxl4tjh6revJWFt2spzzVcB7JlxpnBd7QZ9IY=; b=HqGZb1lvvidh/w5Hph9DCHLPW5iz07Cr2GLpnhTixSja6/JECgdXB2ceivEca+NeyH gNJeHX91usLEbJQ0/8eFMoK8VsreIS8q5JAd2SXvyMCYSyQlezrx6nwEeBdOUO7eaG3P Mi6L0/7j4r3POK5fdYGvN03OlQm+HDpLlM3Qcp8sha3K1Baz4WSRjaQuUcmCvvJsE2MV DZTrNRfSdFxOVnboSLjTclDKKs0jylAl1sJQIpMT01qpEXyR+FbnwjzkVsmectefYSlB pSvlpIF07GRFlB1GFC0jq2hao9ZnvdrRyPUF+7vBkhzuMrKhkDdLr0w49mH8xKTzD3Ck 8gQQ== MIME-Version: 1.0 X-Received: by 10.43.16.196 with SMTP id pz4mr46324842icb.69.1426133162111; Wed, 11 Mar 2015 21:06:02 -0700 (PDT) Received: by 10.107.156.75 with HTTP; Wed, 11 Mar 2015 21:06:02 -0700 (PDT) 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> Date: Thu, 12 Mar 2015 00:06:02 -0400 Message-ID: Subject: Re: [PATCH] Finish the task 'Convert mountlist_mtx to rwlock' From: Ryan Stone To: Tiwei Bie Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-hackers@freebsd.org" , mjguzik@gmail.com, wca@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Mar 2015 04:06:03 -0000 On Wed, Mar 11, 2015 at 9:10 AM, Tiwei Bie 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)