From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 12 04:44:43 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 7F2B4185; Thu, 12 Mar 2015 04:44:43 +0000 (UTC) Received: from mail-pd0-x230.google.com (mail-pd0-x230.google.com [IPv6:2607:f8b0:400e:c02::230]) (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 45F5064A; Thu, 12 Mar 2015 04:44:43 +0000 (UTC) Received: by pdjp10 with SMTP id p10so16902496pdj.10; Wed, 11 Mar 2015 21:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=mgmEVoAVOD3zyg3QoQklC88z9S6FwKHqGivKdiL1bQ4=; b=nxlAPFBc9aR2YT/artThLBXKZacgCVnv8qvFqqwjiCNtvpJUuC6gpfGqMgkY2zGq3T VfOQgDO6uVas0f5tI2udanSSh8ClTfc/zJQ7JFQxKVe5K8MF//AKcO0wKcaJM0wU1rUm eVgw5D8E4D89qf3UBUVIo9kNIH9yEOhps4haBteflq6hu4dQv4edvx9GpZmKFji/RpIa 7Dtv5nZAB2UFCFuE8JQNwpVndzoJcZ0b4/Um/ip+tPqbkT0NYZrHvErKBt5SFtirRvjU 0UXteG2vhxcYwM+AgzlQUelqY1ImMQYAxmHjUBT+cvt5wiHCdksTdDfhLz74IQa7+KgE uaMg== X-Received: by 10.66.118.129 with SMTP id km1mr85829800pab.112.1426135482727; Wed, 11 Mar 2015 21:44:42 -0700 (PDT) Received: from raichu (216-243-33-91.users.condointernet.net. [216.243.33.91]) by mx.google.com with ESMTPSA id jj1sm8609137pac.17.2015.03.11.21.44.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Mar 2015 21:44:41 -0700 (PDT) Sender: Mark Johnston Date: Wed, 11 Mar 2015 21:44:39 -0700 From: Mark Johnston To: Davide Italiano Subject: Re: [PATCH] Finish the task 'Convert mountlist_mtx to rwlock' Message-ID: <20150312044439.GB11120@raichu> References: <1426079434-51568-1-git-send-email-btw@mail.ustc.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Cc: "freebsd-hackers@freebsd.org" , Tiwei Bie , Mateusz Guzik , Ryan Stone , 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:44:43 -0000 On Wed, Mar 11, 2015 at 09:14:49PM -0700, Davide Italiano wrote: > On Wed, Mar 11, 2015 at 9:06 PM, Ryan Stone wrote: > > 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: > > > > 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.