Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1400838lqp; Fri, 22 Mar 2024 13:48:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWExN1tcJ+MbZD+QGQldSD4lRlcAFYoWRf3qmtxfF5VeY1YUMZE0JsgDTwN/cVmyQBewt17Ky0unC0Y4NS9CDIZNhzTpgHU+NKaeM9dcQ== X-Google-Smtp-Source: AGHT+IG8MGEi92VQZKhX+YWlZXC+EnXI50K6rFeNP4iBMZvYyYtoil8npgAyb0s2qCl+ki6VgVc0 X-Received: by 2002:a05:6870:b4ab:b0:221:7388:87c4 with SMTP id y43-20020a056870b4ab00b00221738887c4mr1055460oap.55.1711140506093; Fri, 22 Mar 2024 13:48:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711140506; cv=pass; d=google.com; s=arc-20160816; b=zm1CFF0CB4B3tDmrutnXsEXTEEONqXlUXjOC2SERcPEZJaFIM3+MJOwp0AkPUfjjwy OKJanDZJu7dcdR5R2nv0ZNyuYtjXL3gr2mabnCCDFrpgzNt45WatXFZ+WdYlf6x2cKpj Y0m4EEM/jP9lt8MjLd9tXnmV8q/odT3R1TH9v9NzjxVFRBZ9yeRlVKPDTrTH4v6j5LSS FktJ2A0Da+9TNQRmotUILU1nca/ca1+m/mZnrJVSlIMF4An1XLcxBe8MAApFSjUdhQIE HQZRoaCepQWkdNZrXikDIvaBWul+jDYc59L9fNLRf2SspN/UfRJl61+sqHEkzIOwzl9D 6mzg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=cXBx3VzR7N2fMDvYA3V58Tg2o06qBU1Dh6GmugdLhiM=; fh=lJmh2qM+cYA3xnJMaIkTE0BTNXNzt3GMuMXRMnEe3dA=; b=MEImnWvmRbJqulLP6Jz4RYn0dE04U+mGoQJNZkOMcmXj9ISqPF1/kTE9OTwpjfIE74 z+nQeNMwXY0CwgyDXnm1gyo4G7Gp6GDxBdl/v3VspzCKTs0+7ujpfJO1um4I1SisC7rA bnj84FjVELfVpbNCk5Fc41oqB6JeWnlAN613DfkIPXCBSozBvD8AnL67FECh+Ok4JIbT IglULxzQwsveRx+Gvp726w5s5LZgG6nLk1Isg6baQz2djEviRG8QbVLq370AiQhiT78I 0CKbPTe4dt1erbchYrDKV+Mc4VBAHucPh7kP4WbAWO4PmPmUmKZYAOP7Yn+vJb41gqMY edmw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=QVRAKzAU; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-112019-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112019-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j2-20020a63fc02000000b005dbcf612461si2792081pgi.416.2024.03.22.13.48.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 13:48:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112019-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=QVRAKzAU; arc=pass (i=1 dkim=pass dkdomain=linux-foundation.org); spf=pass (google.com: domain of linux-kernel+bounces-112019-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112019-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B53F328410E for ; Fri, 22 Mar 2024 20:48:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEEAF7F7FA; Fri, 22 Mar 2024 20:48:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="QVRAKzAU" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC7765D72F for ; Fri, 22 Mar 2024 20:48:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711140500; cv=none; b=YfmUXdCVJCG/R6jS8fHPwSwjGeOTnpVzQz84nyuhrrE8sapmU9Pcr6/BEVBMjHKUjBb7Rm+FktkpF12zTqEwtnftUGxQG1pLZgPhjtduRR8tkTSVBml+lReNkMJleOXaqARmuREHW1v/DXeXWtrzQdQu6UeZzrnf1fhrp4iJRlY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711140500; c=relaxed/simple; bh=Uf9dSpYITp6bxdnwZZqCFp6GDVfEBgn7BjvTh1fsU0E=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=Q8UxtldhPo/87Woe/IKPnSn/l+p1cMzrr+5wVXFfO1hQov3GfG5lSqWQmN9laY178apDfrveNJpyfR4gATloX41KGklZaSsAaABUubcaoPk43KNLUTKALOpJiGKUZf4EqIZuqJOEd/QHOdGeoxPkyAOMEiNcUJxmcH940KY2bUQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=QVRAKzAU; arc=none smtp.client-ip=10.30.226.201 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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.