From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2896CC43331 for ; Thu, 7 Nov 2019 19:54:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D36DE21D79 for ; Thu, 7 Nov 2019 19:54:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="YEY7FbEs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D36DE21D79 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8AF646B0008; Thu, 7 Nov 2019 14:54:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 85FD66B000A; Thu, 7 Nov 2019 14:54:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79CB86B000C; Thu, 7 Nov 2019 14:54:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0077.hostedemail.com [216.40.44.77]) by kanga.kvack.org (Postfix) with ESMTP id 628DF6B0008 for ; Thu, 7 Nov 2019 14:54:55 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id CC1EF824999B for ; Thu, 7 Nov 2019 19:54:54 +0000 (UTC) X-FDA: 76130534508.05.song69_47f405a7f8a3e X-HE-Tag: song69_47f405a7f8a3e X-Filterd-Recvd-Size: 3388 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 Nov 2019 19:54:54 +0000 (UTC) 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=b3XWyTAN51GGwQJ3OlvxFEJCrV0vrJRe7r0j72I5jss=; b=YEY7FbEs/hXtr23AaFaDCMKpD F+IUHJedCBPdXSl99gAwF6mBor6wPNYioameeGYSF+SxQFF0yp18uSo9dtG9qwnnrpzhbJu0TsTEh 0AjT5YRo6bJCUGbEmA5Vy/K6jrnT3j7a2kB7AlLV9nnvGhtd6PuIPj9mBQ/tFcDmHd0TFBToBVEJY lmf+lDhCMW18IybY0IB69ss+rIDT/O0RoVXwT593e0997jrK1GK7iw4ih1oA2lgFE+WXIXd+MC2Wi ZFcQClN9ipj5msOzRbr+2lwacZM9wQwO8krbanqn8v+FnbLkGuHMe33Re3PQV/RAOOERyUUT78qMu eNFQulWXQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iSnrd-0003ym-EM; Thu, 07 Nov 2019 19:54:41 +0000 Date: Thu, 7 Nov 2019 11:54:41 -0800 From: Matthew Wilcox To: Waiman Long Cc: Mike Kravetz , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Davidlohr Bueso , Peter Zijlstra , Ingo Molnar , Will Deacon Subject: Re: [PATCH] hugetlbfs: Take read_lock on i_mmap for PMD sharing Message-ID: <20191107195441.GF11823@bombadil.infradead.org> References: <20191107190628.22667-1-longman@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191107190628.22667-1-longman@redhat.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Nov 07, 2019 at 02:06:28PM -0500, Waiman Long wrote: > A customer with large SMP systems (up to 16 sockets) with application > that uses large amount of static hugepages (~500-1500GB) are experiencing > random multisecond delays. These delays was caused by the long time it > took to scan the VMA interval tree with mmap_sem held. > > The sharing of huge PMD does not require changes to the i_mmap at all. > As a result, we can just take the read lock and let other threads > searching for the right VMA to share in parallel. Once the right > VMA is found, either the PMD lock (2M huge page for x86-64) or the > mm->page_table_lock will be acquired to perform the actual PMD sharing. > > Lock contention, if present, will happen in the spinlock. That is much > better than contention in the rwsem where the time needed to scan the > the interval tree is indeterminate. I don't think this description really explains the contention argument well. There are _more_ PMD locks than there are i_mmap_sem locks, so processes accessing different parts of the same file can work in parallel. Are there other current users of the write lock that could use a read lock? At first blush, it would seem that unmap_ref_private() also only needs a read lock on the i_mmap tree. I don't think hugetlb_change_protection() needs the write lock either. Nor retract_page_tables().