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 5196EC47DD9 for ; Sat, 23 Mar 2024 00:46:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CECA66B0085; Fri, 22 Mar 2024 20:46:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C76606B008A; Fri, 22 Mar 2024 20:46:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC8DC6B0092; Fri, 22 Mar 2024 20:46:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 963FB6B0085 for ; Fri, 22 Mar 2024 20:46:09 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 386C514087D for ; Sat, 23 Mar 2024 00:46:09 +0000 (UTC) X-FDA: 81926462058.01.19A249A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 1EE291C0016 for ; Sat, 23 Mar 2024 00:46:06 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Suxl2RdS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711154767; a=rsa-sha256; cv=none; b=4DnR09+TZtjEQ4FK6twneGrq23DJT69s++3uVXjIOwwaKOHpX8kZEk4RXIoageBZ+EPfFW 1kro5S92T66HzcvtqgmKQ31kx0u1RjdJ5LxFnq6QIo5noz3fds+Agy4L+IIIyVaNHJMWEx lGNSrhwelvDRgEdM+vvQba4+9h/6bGM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Suxl2RdS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711154767; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1OPeHdcChNLXNL4AZVVP+Dj6erLbPxRFcj0CZKU2hHc=; b=J/T9hkUK5qiCchFQB/zQMfAUes5jpXIdTOXh2E/Dg9Pni7KVK51QVSD77dnzQjqHDYyY1S bG3dtrIkYk+cyD4JLCVRTp/X0srfvYXsQ8SpdoVfqazpbjtQnKZiYvOlddW+GR7ShL0j6d /MgbAnicfZpW7Mv283G2JKxe+Pq3774= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711154766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1OPeHdcChNLXNL4AZVVP+Dj6erLbPxRFcj0CZKU2hHc=; b=Suxl2RdSBOkopv3J73sHPjioyuGHRS4/2uhrnSDvYT8JbetMM5yZ5o7woN6co+uKZr9IJB ggX1f15JnW3e6RCJQQTjNRDSIHA4XsXfna9LL9jHhTKaj37yPCaoznSXlBGdpNoKZigdxJ e9gV/uG2iamfDlVJHMXQ4pyJZs1se5w= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-jKShytGePXSIahKo8wpvhQ-1; Fri, 22 Mar 2024 20:46:05 -0400 X-MC-Unique: jKShytGePXSIahKo8wpvhQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-789f8bb05e8so43850485a.0 for ; Fri, 22 Mar 2024 17:46:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711154763; x=1711759563; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1OPeHdcChNLXNL4AZVVP+Dj6erLbPxRFcj0CZKU2hHc=; b=c0rFAKG0Z2VhGgtJ1d6cQ/uBD4S2cNCN7rOBVEq+Vhxw/ZQQQYtUABp8Co5llGbMPU ikeO58g1gNtPhaHLm5eypFLBk9ldKWZiMb6/DNTV0qUPMavixYi2kmUwho8vlH1GWqTF dpuBWxum/00VY7yjx+y5Lf4ZG3/Rtc0gqkTjyoOneMBoJ9v2Hg+PiR0oPXlYNpnYpPxR 5Tw6dIvYwmeJFI2faN9mGWucmf3PVXUwVrfOTo7ACIpHVeptYJlVI16H2S/uh3oOd9nw FuDyjT64Ina2G7vXvgQRTNIENpdTzUytB5X6xpR3khnt8bzXcGQY5UitqKllawBFE+49 +0yQ== X-Gm-Message-State: AOJu0YyF0tJjdeYQJmnYR1c2yPgvom/NDw9V4vekH8UuKSqiiPWX9nW5 l30mYPbkgJybj6Ecv5787BSD1Z0hIcxvwVt3AkoknvgW36lVlwn5yrw3soti/Dz5+KmyDJCWSkU n559Trt7W2S7js/anWq76+MfDiims/vfNeD1qqAmZiBoeJbpL X-Received: by 2002:a05:6214:3d8c:b0:696:1892:c19f with SMTP id om12-20020a0562143d8c00b006961892c19fmr1028556qvb.3.1711154762749; Fri, 22 Mar 2024 17:46:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxKOcFDVxpG3qeQleX58Tuq2r0TaBTmm4VWGOLqVds86GEmp/lVpAtwxST9mY/JIaYF94G+w== X-Received: by 2002:a05:6214:3d8c:b0:696:1892:c19f with SMTP id om12-20020a0562143d8c00b006961892c19fmr1028507qvb.3.1711154762082; Fri, 22 Mar 2024 17:46:02 -0700 (PDT) Received: from x1n ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id jf8-20020a0562142a4800b006942dcac56asm1567334qvb.103.2024.03.22.17.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 17:46:01 -0700 (PDT) Date: Fri, 22 Mar 2024 20:45:59 -0400 From: Peter Xu To: Andrew Morton 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: References: <20240321220802.679544-1-peterx@redhat.com> <20240321220802.679544-13-peterx@redhat.com> <20240322134818.9b312f77629f79fcf1564b6f@linux-foundation.org> MIME-Version: 1.0 In-Reply-To: <20240322134818.9b312f77629f79fcf1564b6f@linux-foundation.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1EE291C0016 X-Stat-Signature: frqzhzhwpez1x15681apwkxafz4msdwe X-HE-Tag: 1711154766-701758 X-HE-Meta: U2FsdGVk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6l4UaluU1KfqMmNy9HIuEfNcJuz+YPrmfK+Vp09JZeX7FMdV6HRU6D5IfzPSHsyvfqWU8ixFYhBQaaMyqHDUydmstA06OcpEuN2AXiXOrKsyRLRu2n2dS485QIg9S8d9IYrUCUw8JoEhglWzyhHGQY5Q4M3lYGbZN9Gu/ZqhJ2/sp78HaY4ar7Cy3elC64lsow3yhLe5u+H7UoVSAyvfAJD+rUh51r9CNMya3TPRICXqtCk0p89DdE6hlT8NKii6SFBw1gysctym+Sz5mfB9rhoiitvcexu0PrRNRlk5jW1xkUZfLDvcwUYCCrMtLga5NsCbiKSsEuF5uGQ== 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 Fri, Mar 22, 2024 at 01:48:18PM -0700, Andrew Morton wrote: > 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. Andrew, Apologies for that, and also for a slightly late response. Yeah it's time I'll need my set of things to do serious build tests, and I'll at least start to cover a few error prone configs/archs in with that. I was trying to rely on the build bot in many of previous such cases, as that was quite useful to me to cover many build issues without investing my own test setups, but I think for some reason it retired and stopped working for a while. Maybe I shouldn't have relied on it at all. For this specific issue, I'm not sure if CONFIG_HAVE_FAST_GUP is proper? As follow_hugepd() is used in slow gup not fast. So maybe we can put that under CONFIG_MMU below that code (and I think we can drop "static" too as I don't think it's anything useful). My version of fixup attached at the end of email, and I verified it on m68k build. I do plan to post a small fixup series to fix these issues (so far it may contain 1 formal patch to touch up vmstat_item_print_in_thp, and 2 fixups where I'll mark the subject with "fixup!" properly). Either you can pick up below or you can wait for my small patchset, should be there either today or tomorrow. Thanks, ===8<=== diff --git a/mm/gup.c b/mm/gup.c index 4cd349390477..a2ed8203495a 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -30,11 +30,6 @@ struct follow_page_context { unsigned int page_mask; }; -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); - static inline void sanity_check_pinned_pages(struct page **pages, unsigned long npages) { @@ -505,6 +500,12 @@ static inline void mm_set_has_pinned_flag(unsigned long *mm_flags) } #ifdef CONFIG_MMU + +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); + static struct page *no_page_table(struct vm_area_struct *vma, unsigned int flags, unsigned long address) { ===8<=== -- Peter Xu