Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1441702ybx; Thu, 7 Nov 2019 11:56:08 -0800 (PST) X-Google-Smtp-Source: APXvYqw4JfZRIM6Q8ImJ3DwP6tKMdP6gutXrdrniCYvPVbNggHdmoLhvojZTjVNPoTibJhrZgcOs X-Received: by 2002:a17:906:5448:: with SMTP id d8mr4825924ejp.79.1573156568048; Thu, 07 Nov 2019 11:56:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573156568; cv=none; d=google.com; s=arc-20160816; b=gQcK39GQpC2RYBN0FhD8EEzqwVAn3+mdMMWfOPnyqo/W54GaX4IcXpFFe5IVR7kgMn 7gnUUltVAUZhmMZ5lNdRKCx+OwXJdwCtYailVEz3gHsW0o1uX6TPXBfS/2Ysuj5t5Dwi Mcaj9B7IgI6Q6mpf1WWeoVJmMsely6+jRpCIldXeac3Y+lhVqPGcHl+pFua8oyU39tHf NPPBkAL2XPny8uKzeGUhIYIxdSpoNhc7QIOq391+cmntH1I84jY3YUlRnOIscEH6BFh8 qQXxbYWLAKVVZnAJ+Tn/z7J6RO3QL47RfzYnCQ7yM8loLv5SyKgnRgpsDPy/j9L+Nhjc 002g== 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=b3XWyTAN51GGwQJ3OlvxFEJCrV0vrJRe7r0j72I5jss=; b=qWjtn7+XGQdNtu//ZmWfuc+gIr4TdNrHl1H+T+tswWmOV8ACuCjyW4M4wBgEPzC8sS I7zvbWYKlqV/zzBkrafvXAQYQjpr7xzahpzmieSAnfIY6DuTpL7EN+iTEq+gkGNEL0M4 tL1jMKNXiFrMq2JQ9FyCb8EwEUM+miOuHbE11UOVBjf52igNaJRzct/l861gOtBVop5w c5JUF8x6GSSaO+53Z21mn0JfWUqbQF4Dfl9/QeimlZ0VLM7cQogFh6m5M4RZex//9vJI ldUN7G7Gwkkg3JEGnzCEBlsYng4flmWpoersLX3cgP+hahfLPrBItqSKvxOcIcUDeXh0 nXxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=YEY7FbEs; 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 nf6si2141161ejb.406.2019.11.07.11.55.44; Thu, 07 Nov 2019 11:56:08 -0800 (PST) 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=YEY7FbEs; 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 S1727295AbfKGTyp (ORCPT + 99 others); Thu, 7 Nov 2019 14:54:45 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:41980 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725818AbfKGTyo (ORCPT ); Thu, 7 Nov 2019 14:54:44 -0500 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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().