Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1737866ybe; Wed, 11 Sep 2019 21:31:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYKlgH7lNlfpA04jxFj+yyOpMFBWELY3ehsb5XDBICGkq/f88bxjbLyDa+rv02cVqaje8t X-Received: by 2002:a17:906:d922:: with SMTP id rn2mr32198929ejb.169.1568262674774; Wed, 11 Sep 2019 21:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568262674; cv=none; d=google.com; s=arc-20160816; b=aFiJhstUCcq97vNWDhKNGsOD53MkO4Kd2mjz0rUAlflZcd475IOdqey8iPoQjeRX2c eg+FpcsVAIMDKRLzOZhvL5J+1ih+4wT6gQzJnt53LiJc/7X5HUhBrL7YiA+Y1xKVIGWD lLNTwm5YM8aw0vupAB5Jz3f+Ux7N3J6cnBhWIaAT8fqtmrN3rOFotLZckOenVZD4AITW OCi/5381c5jwg4822vZG8EIE+5eivGe+GpYj8hc2OlPNcB9koLubpN+DNbxBL+nqHF/g rLEF8+/2WgiqkHKHd+JEU/2bmSZ0rnNUDuqqo3tTn8PRYhMqsSTbXCW1NmL6KyCBBMvW w/FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7EwQtG2hwlINClUDNZab/A4gQX9VeexXatbSrvMQs9I=; b=JTX1NAMoEuImEQO4SUwVdAUcU9rnAUDNsdE5nTvt4sY7XdMCIkkyphCRNsYtcTEtPf nnviWAVX+IF/F0X/BECUWxAy7U4+Hu30V/FsyVpF69nWWcT5UQrEGGRQgZfwPPoI2YlO 16vojeEUoV/bNpKpWkKrM5mDQ4+fHFw7p2lV5EfiBJCDJPYv6h40XbJzT+Z38LLDSRdk AOxNsgS67r7riiAkxgmm0RpKUlVOEiREX6fNvr3bgydxeZf4i4vc6Y8FPwZVTFWnvLsp a4aSiUGUpNy/DP+YgZl6Y1gMgURHbVNbTXp1BT3kzP6q5cF3lfu8RSvU+/iNIOu/bi8O FmlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Fnr+FH0I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d48si15517002eda.383.2019.09.11.21.30.49; Wed, 11 Sep 2019 21:31:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Fnr+FH0I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729307AbfILDlt (ORCPT + 99 others); Wed, 11 Sep 2019 23:41:49 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:35160 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbfILDlt (ORCPT ); Wed, 11 Sep 2019 23:41:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7EwQtG2hwlINClUDNZab/A4gQX9VeexXatbSrvMQs9I=; b=Fnr+FH0Iq5wsSebY0xIvcvz3a ARsc+bxbp6X4Wqlhor8mTnGmujrqXxtXRHIZ14oZo77yUethMpwVRQi9ulUznP7ifhisPFAWNfhU6 hzezfQxpYC1iIJHL3c0LAHn644O20BB0hxpJOQ0acyTjBM0ix6/zhnCHRGKH12WLpeIQQMnFaYSar ZaDp293HOeh3fUq01D9vYyp1fr1pcDMt5A02u4FPasLEsD7Mf30jcvwR+M3cyarD08JgU7LqVqR4K q+vvN827RZdUkJ8BrqdcgENp3zgvAY8FpMpyAkf0nj51CsJn7gCJVX6WOjIerx1fRtAGvXbKE321s 7CufzKEVQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1i8FzL-0002e3-4X; Thu, 12 Sep 2019 03:41:43 +0000 Date: Wed, 11 Sep 2019 20:41:43 -0700 From: Matthew Wilcox To: Mike Kravetz Cc: Waiman Long , Peter Zijlstra , Ingo Molnar , Will Deacon , Alexander Viro , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Davidlohr Bueso Subject: Re: [PATCH 5/5] hugetlbfs: Limit wait time when trying to share huge PMD Message-ID: <20190912034143.GJ29434@bombadil.infradead.org> References: <20190911150537.19527-1-longman@redhat.com> <20190911150537.19527-6-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 11, 2019 at 08:26:52PM -0700, Mike Kravetz wrote: > All this got me wondering if we really need to take i_mmap_rwsem in write > mode here. We are not changing the tree, only traversing it looking for > a suitable vma. > > Unless I am missing something, the hugetlb code only ever takes the semaphore > in write mode; never read. Could this have been the result of changing the > tree semaphore to read/write? Instead of analyzing all the code, the easiest > and safest thing would have been to take all accesses in write mode. I was wondering the same thing. It was changed here: commit 83cde9e8ba95d180eaefefe834958fbf7008cf39 Author: Davidlohr Bueso Date: Fri Dec 12 16:54:21 2014 -0800 mm: use new helper functions around the i_mmap_mutex Convert all open coded mutex_lock/unlock calls to the i_mmap_[lock/unlock]_write() helpers. and a subsequent patch said: This conversion is straightforward. For now, all users take the write lock. There were subsequent patches which changed a few places c8475d144abb1e62958cc5ec281d2a9e161c1946 1acf2e040721564d579297646862b8ea3dd4511b d28eb9c861f41aa2af4cfcc5eeeddff42b13d31e 874bfcaf79e39135cd31e1cfc9265cf5222d1ec3 3dec0ba0be6a532cac949e02b853021bf6d57dad but I don't know why this one wasn't changed. (I was also wondering about caching a potentially sharable page table in the address_space to avoid having to walk the VMA tree at all if that one happened to be sharable).