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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF506C54E71 for ; Fri, 22 Mar 2024 20:48:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 050806B007B; Fri, 22 Mar 2024 16:48:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F1B3B6B0082; Fri, 22 Mar 2024 16:48:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE3716B0083; Fri, 22 Mar 2024 16:48:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C876F6B007B for ; Fri, 22 Mar 2024 16:48:28 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 950A0A1C56 for ; Fri, 22 Mar 2024 20:48:28 +0000 (UTC) X-FDA: 81925863096.26.D204684 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf16.hostedemail.com (Postfix) with ESMTP id 2BF4918000A for ; Fri, 22 Mar 2024 20:48:24 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=QVRAKzAU; dmarc=none; spf=pass (imf16.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711140505; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cXBx3VzR7N2fMDvYA3V58Tg2o06qBU1Dh6GmugdLhiM=; b=RniMEXx0xVLOcd35xwMlKt6J18w4Gzn54alQ7q/MXcZoHh16r1KxUH53t/EeYWfi+nmmZC v2ov3YbMDXl7IwtqmuINOXdcaAWnhAEaOtF6yHpGA68gkCHcv2G0tdcrVyjM4lpixQRElH GKuRllI88eR6Gc0GnDACDYNzlr9Vmrs= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=QVRAKzAU; dmarc=none; spf=pass (imf16.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711140505; a=rsa-sha256; cv=none; b=J2uPaNpE9Iawfkxb2AnaK0jjSgzmG8LYrYVrIdF4IYsVErxioj2s69/1tTUJXesV19Tnlr RuVjtVMp0lYMV8OV4i3GoNqyH+s7maxRRSvIHwsp3Zhk/cIV9TYhaQb/REIFwjyR0BGiIA y7SHUhvVEBHIY0j+yKX9cdm3MlYBaAU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 5D07ECE182D; Fri, 22 Mar 2024 20:48:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C52B0C433C7; Fri, 22 Mar 2024 20:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1711140499; bh=Uf9dSpYITp6bxdnwZZqCFp6GDVfEBgn7BjvTh1fsU0E=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QVRAKzAUPqWp2P8fFfJjymQCiqf8/IWwd1wmqWmnRlxsqAjKHpKVO/2FMY54BdYVe MtuhTuaPMg1SbalsaWAguHK6KathmRCmewglEhgp1kUsqyLrxGR7rhkCkBiCs/cIST Foh0xWAZf8YKEf1Z8kAQrZNZWmXaYiyM/6VzFqZo= Date: Fri, 22 Mar 2024 13:48:18 -0700 From: Andrew Morton To: peterx@redhat.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Christophe Leroy , Matthew Wilcox , Rik van Riel , Lorenzo Stoakes , Axel Rasmussen , Yang Shi , John Hubbard , linux-arm-kernel@lists.infradead.org, "Kirill A . Shutemov" , Andrew Jones , Vlastimil Babka , Mike Rapoport , Muchun Song , Christoph Hellwig , linux-riscv@lists.infradead.org, James Houghton , David Hildenbrand , Jason Gunthorpe , Andrea Arcangeli , "Aneesh Kumar K . V" , Mike Kravetz Subject: Re: [PATCH v3 12/12] mm/gup: Handle hugetlb in the generic follow_page_mask code Message-Id: <20240322134818.9b312f77629f79fcf1564b6f@linux-foundation.org> In-Reply-To: <20240321220802.679544-13-peterx@redhat.com> References: <20240321220802.679544-1-peterx@redhat.com> <20240321220802.679544-13-peterx@redhat.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2BF4918000A X-Stat-Signature: 4hiitx3e79zas3rihaw5h8px34na5yqj X-HE-Tag: 1711140504-428015 X-HE-Meta: U2FsdGVkX1941GBt9zfRh6TdqHN6QbRdOG2RWBMgytQvDvYu2rAKobhkJe1vRNJgR7AqOk6o7yhSIfE7OSo+Nnof6OCUH6bAXk1TapRehBtRsfw26k7cGrlDcKSLO95KY/qHdflMVo0HSpW5DiehTmSK5tOuacArMeWpttkxU3jVQlTnabFwnw9tcMj9fr7V71/eRlQuXjp6JUl/ka+9d8he7M3JORrYiNSS1d+AWGPN9Vyjgy5lqczmLuvGe1DmsgUNEFJe0xYlKLAJw76ogQr+eJsKm+p9aWCZvZI4e26rTxv3qxr1ip+NieCQWaCU4UdB0gdsyFeXH9Eg4VqOg9UgyFu+f3ObtNEK6eGCGwo4qxtasiY4KlTE9Z9jubIBXqYBQqHSqm+TK9v60A3hJyntipYs3uzc3HmXxgixB9PmPE6b4wIEt2yAx7I2EAJDFQd55mgpj+fXFejr4D0ETGAXyMEw5PqR9hoUuBhVYNlBRuKyhqCOUoIITGESW9AwOUw9IH9H6sicG/tDiOdr3VXE9G3LQaIV8Gi4kQ+0Fh5pz36X3qa2dxDhg9Tbk6fTFI+tovJRohMeU9ynIh89WCjQHxpGPahjiV1yNEdv9JS6A4eO/5eocwxuSOX09PCfb4VovG6xS/nkqKdkTWPGzE/d7RQIwihXiVVtthg7K2EyMXs3mlP3imlO4eH7LXKLhl6b03ld4z/Pqd5cxmhCmaExK1jjywVyU7f9nkB7ppMX9sXo9+rL6wyyaukZZoow8H+cVpUgaEm6Oq5qC8/k7MggMttJ3Fb0ayXDZmDx5PYgKcwn9d9mScrti8+hbkN+3stnL2MNCL47zygZ4CAEfD6E1J/TXlTotRh6vP3IRDydweXUondn4yQkPMvaKBUEiXRewIYeGkNdhuglLYfX2Pasr6O8Pkf6dc7bSS/twDKJgGl3mm+A420P5nwRw1eKzMt3yFY4c+71j6Dk2K/ 8kQKY1kT gtqZTKObtarRnirgDh4RrWuA2amJ6Q/YhKxf2BX/PE368lSmZQ0N69NcKyDqsFsljoxE49pJ1Xq45xY6s/2dTKzTMRQRYBVSFp3tL3W4OLFGQRepLTA+cj9/uAbz4bqMsZa/4uvhclPiPlWOGe472209NiCrn2FuSA/Ze36CHNJ8T4fdvVBszl3LVYRSjobecXqNFz9jltHqUbo3AHChJwreDBTiwviGrsivD0SbWglRKliMDzceDR4M4xfeKbvEwdIfC9w66I+roGSMY1N5kth/foyc9xsaoGH4++/mwz5DNdrM= 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: List-Subscribe: List-Unsubscribe: On Thu, 21 Mar 2024 18:08:02 -0400 peterx@redhat.com wrote: > From: Peter Xu > > Now follow_page() is ready to handle hugetlb pages in whatever form, and > over all architectures. Switch to the generic code path. > > Time to retire hugetlb_follow_page_mask(), following the previous > retirement of follow_hugetlb_page() in 4849807114b8. > > There may be a slight difference of how the loops run when processing slow > GUP over a large hugetlb range on cont_pte/cont_pmd supported archs: each > loop of __get_user_pages() will resolve one pgtable entry with the patch > applied, rather than relying on the size of hugetlb hstate, the latter may > cover multiple entries in one loop. > > A quick performance test on an aarch64 VM on M1 chip shows 15% degrade over > a tight loop of slow gup after the path switched. That shouldn't be a > problem because slow-gup should not be a hot path for GUP in general: when > page is commonly present, fast-gup will already succeed, while when the > page is indeed missing and require a follow up page fault, the slow gup > degrade will probably buried in the fault paths anyway. It also explains > why slow gup for THP used to be very slow before 57edfcfd3419 ("mm/gup: > accelerate thp gup even for "pages != NULL"") lands, the latter not part of > a performance analysis but a side benefit. If the performance will be a > concern, we can consider handle CONT_PTE in follow_page(). > > Before that is justified to be necessary, keep everything clean and simple. > mm/gup.c:33:21: warning: 'follow_hugepd' declared 'static' but never defined [-Wunused-function] 33 | static struct page *follow_hugepd(struct vm_area_struct *vma, hugepd_t hugepd, | ^~~~~~~~~~~~~ --- a/mm/gup.c~mm-gup-handle-hugepd-for-follow_page-fix +++ a/mm/gup.c @@ -30,10 +30,12 @@ struct follow_page_context { unsigned int page_mask; }; +#ifdef CONFIG_HAVE_FAST_GUP static struct page *follow_hugepd(struct vm_area_struct *vma, hugepd_t hugepd, unsigned long addr, unsigned int pdshift, unsigned int flags, struct follow_page_context *ctx); +#endif static inline void sanity_check_pinned_pages(struct page **pages, unsigned long npages) _ This looks inelegant. That's two build issues so far. Please be more expansive in the Kconfig variations when testing. Especially when mucking with pgtable macros.