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=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 4715CC32792 for ; Mon, 30 Sep 2019 21:51:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 05D9720842 for ; Mon, 30 Sep 2019 21:51:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="UzrMa92U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05D9720842 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A442B6B0005; Mon, 30 Sep 2019 17:51:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1BFC6B0006; Mon, 30 Sep 2019 17:51:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 959B36B0007; Mon, 30 Sep 2019 17:51:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0094.hostedemail.com [216.40.44.94]) by kanga.kvack.org (Postfix) with ESMTP id 73FD26B0005 for ; Mon, 30 Sep 2019 17:51:39 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id 1345D181AC9AE for ; Mon, 30 Sep 2019 21:51:39 +0000 (UTC) X-FDA: 75992934318.16.can90_2b49104324f52 X-HE-Tag: can90_2b49104324f52 X-Filterd-Recvd-Size: 5850 Received: from hqemgate16.nvidia.com (hqemgate16.nvidia.com [216.228.121.65]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Mon, 30 Sep 2019 21:51:37 +0000 (UTC) Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 30 Sep 2019 14:51:43 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 30 Sep 2019 14:51:35 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 30 Sep 2019 14:51:35 -0700 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 30 Sep 2019 21:51:35 +0000 Received: from [10.110.48.28] (10.124.1.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 30 Sep 2019 21:51:35 +0000 Subject: Re: [PATCH v4 03/11] mm/gup: Applies counting method to monitor gup_pgd_range To: Leonardo Bras , , , , , CC: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Arnd Bergmann , Aneesh Kumar K.V , "Christophe Leroy" , Andrew Morton , Dan Williams , Nicholas Piggin , Mahesh Salgaonkar , Allison Randal , Thomas Gleixner , Ganesh Goudar , Mike Rapoport , YueHaibing , Greg Kroah-Hartman , "Ira Weiny" , Jason Gunthorpe , Keith Busch References: <20190927234008.11513-1-leonardo@linux.ibm.com> <20190927234008.11513-4-leonardo@linux.ibm.com> From: John Hubbard X-Nvconfidentiality: public Message-ID: Date: Mon, 30 Sep 2019 14:51:34 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190927234008.11513-4-leonardo@linux.ibm.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To DRHQMAIL107.nvidia.com (10.27.9.16) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1569880303; bh=RhTgQNvZ8M45lzVl6hQTIIr5nfDQ7NW7gfdMi34LNhk=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=UzrMa92UkK/ugI5rJmLH6VcSHCFZgd+8pGsK+O76TQtxxe31sawf/JbOhpwudc/sS damkLuyQvWeeGxVj27E21Eymd67cSEVzDQH3++PnzXsSVS65C5Y/LURmdnD64THCSg 84QKUMhgHJ9PgAoywb3hxCtJw13PuG7Rh+GZJb9kfxzIwoMkTww2a4yBdQl65LtD1r gO9QJ4Gtv+pe7iYDIviNS97kO4OlCkYpCxW61218mxU9ngl1Tk4W1EJZGhLmBHrxc3 ruhDm3XLYrDqzSxy00xKbZ49nSK0O27crTbp/i4he5sCOwb7FST40wueaM69J3/IEs jOVD0C7+kMDwg== 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 9/27/19 4:40 PM, Leonardo Bras wrote: > As decribed, gup_pgd_range is a lockless pagetable walk. So, in order to > monitor against THP split/collapse with the couting method, it's necessary s/couting/counting/ > to bound it with {start,end}_lockless_pgtbl_walk. > > There are dummy functions, so it is not going to add any overhead on archs > that don't use this method. > > Signed-off-by: Leonardo Bras > --- > mm/gup.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/mm/gup.c b/mm/gup.c > index 98f13ab37bac..7105c829cf44 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -2325,6 +2325,7 @@ static bool gup_fast_permitted(unsigned long start, unsigned long end) > int __get_user_pages_fast(unsigned long start, int nr_pages, int write, > struct page **pages) > { > + struct mm_struct *mm; I don't think that this local variable adds any value, so let's not use it. Similar point in a few other patches too. > unsigned long len, end; > unsigned long flags; > int nr = 0; > @@ -2352,9 +2353,12 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, > > if (IS_ENABLED(CONFIG_HAVE_FAST_GUP) && > gup_fast_permitted(start, end)) { > + mm = current->mm; > + start_lockless_pgtbl_walk(mm); > local_irq_save(flags); > gup_pgd_range(start, end, write ? FOLL_WRITE : 0, pages, &nr); > local_irq_restore(flags); > + end_lockless_pgtbl_walk(mm); > } > > return nr; > @@ -2404,6 +2408,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, > unsigned int gup_flags, struct page **pages) > { > unsigned long addr, len, end; > + struct mm_struct *mm; Same here. > int nr = 0, ret = 0; > > if (WARN_ON_ONCE(gup_flags & ~(FOLL_WRITE | FOLL_LONGTERM))) > @@ -2421,9 +2426,12 @@ int get_user_pages_fast(unsigned long start, int nr_pages, > > if (IS_ENABLED(CONFIG_HAVE_FAST_GUP) && > gup_fast_permitted(start, end)) { > + mm = current->mm; > + start_lockless_pgtbl_walk(mm); Minor: I'd like to rename this register_lockless_pgtable_walker(). > local_irq_disable(); > gup_pgd_range(addr, end, gup_flags, pages, &nr); > local_irq_enable(); > + end_lockless_pgtbl_walk(mm); ...and deregister_lockless_pgtable_walker(). thanks, -- John Hubbard NVIDIA