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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0888EC4450A for ; Tue, 14 Jul 2026 15:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fwuFYnIFntaeyFiFTCtuOmdD45sxN5bbxj7Gff2yTa4=; b=acUlWVMIrhS3eaCmWdcLe3U83i 9Vn9H10gi6O2J+GbB5+rGCsdxy1AUVovNdAc8xJtZmZv34wj6epus/eh9PfPsh/Darplwvi6DH71X rp2FP9JasxjZXKaK6alLR17Vy1rb4COK0CsrStjgBEpeeVnH8CTFEUiuxUMQE865hyAI5/02iiOA3 Sa1VdM68v7gZxi7+ew8xuZpa/zIN5cbq2vKGxkfDfqdwe8bIFbcL4HbISOm1PYYu91KFxc7r0LAuV c6GAIlQFLxK+AuDqNZ1Y/JBFNIHKXFPuUJxALjlsW804sPw6uRPLpG9p5nXFh7nu03at2WHsXe160 ZYdU8nuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wjery-0000000CV2A-1eb7; Tue, 14 Jul 2026 15:16:26 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wjerv-0000000CV0A-0KjJ for linux-um@lists.infradead.org; Tue, 14 Jul 2026 15:16:24 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-37e0a189b0bso997630a91.1 for ; Tue, 14 Jul 2026 08:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784042182; x=1784646982; darn=lists.infradead.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=fwuFYnIFntaeyFiFTCtuOmdD45sxN5bbxj7Gff2yTa4=; b=dCdZx7qm1qxuaTabdykrLmfoPr8SFCmMQAqkUv/TIvPwJbr2+nRRvEIGJ5fWjCWFNz J01hg1uSD2z7qzRuQhCXpaZqRSFmUhay9nvi0FLhD/IuaTGZ9t+R40rDliVQsVJVM06c 1t+aZeadSWGsP4bshY3onX5F7xO8jlr71GlndOzFvZN1cRmUGEHGjc3PZW4fykFr2Ryr Q4MRrQaPHt09lNwg5Vq1TynVi3HImWWb1rhRew0mvUmLbn3VzxGRd9FGtvXRnDdPLuwG J5KtWjPpdMoeWr/S211guGXVGGzq7U3LNVDEUQalIgKJiugChT6QndA7yC3sNe/PT0Jp b/2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784042182; x=1784646982; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=fwuFYnIFntaeyFiFTCtuOmdD45sxN5bbxj7Gff2yTa4=; b=MU1PiAmYVNqDtD2PMWuW6LXXpB1SWeBY8IRjMs2KrO+sx00vqb1Lz3J6x2b/9phLOU oaiCCZPiL51oJrdxcwGejY9qaCPkqvOXpFFp8N6dt/zYPWQ5f7Jv8VwF1RSOktJjzHTx i+0cqJa/ltGXga5WkK8Go0WDy6fUWCLNGcCbWKVmiWemlWqoE1OHe9FuwXlc3RHqQx8v GTzVeXOgdaw+JG4EYJlulhn5+Py4KNVsrRUrSNotNxPNjeTdebUvDmmdQjznkqql0O7z JrPhJjBdEunHUSrYz3fGICMYJSJekTqhqT3miBlWJqg4G8osx6Ud1tMCugJuzw/ebKsz EGVA== X-Forwarded-Encrypted: i=1; AHgh+RqjpTZbmE7+9mDZjJzpBohk1RnMQY9D60AeKszcua2f8o2AqTw9qhnzj0zTfThSjPsimkdB6qTXAQ==@lists.infradead.org X-Gm-Message-State: AOJu0YwSYttS933sgfbDeAJB8e89do46pJnJRig6DTlEXC+3/FzvTxaq v0A5kQ462Ukmwxxtsh8AkOHqKLlTFDDAd0euNdcp01kUs/7Y3NY0kN/k X-Gm-Gg: AfdE7ckqLUUslTGqGkFxUZ+kWfErHi5sbV2+IP1P8c0F72X2ztNEOANdJA0OMS868md ZsCyyJLet5t93t2tlaYFfE1EIoPdhWc3mMb645uDGf9BEEzy5dnmHh1lXcMFXML0eKoQ1O55BEe mEszhPNrtrDc5vLkfroVBMQVr1ED1cRGkvvAMoMv7Rk+yvfwwMzKEhyMWVUnnHNiagatKacl78z bUXldKfHANyZYYKc/Puv0RqvLda1xEVWIckTu+Oyy/JfFxr7yGCuEQkVXgWWgah/X0K8lJ+eo8t 1i9yJhM270XU5sc9mGIeGwcuHMpO4ioqoifF65VvizrDLI+ySR8t2/oQHv+srs6ozK+2sZRJ53y Us8jj7tzDKkm+Myh+tLvArhyu4dpC/OHP1pqxGVg6ByRGjvxLBhsGehmfDBUu+kxxxi2p29t/SV S4jzREzC+2zYemjyu+iw0xwF6jneRX05x+LQxpT91Yrfhv X-Received: by 2002:a17:90b:2e8f:b0:380:8b14:d8e1 with SMTP id 98e67ed59e1d1-38dc7b3f8ccmr13234040a91.24.1784042181685; Tue, 14 Jul 2026 08:16:21 -0700 (PDT) Received: from fedora ([2601:644:937c:6c90:6d4e:7b2d:4a39:fb0c]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-313b4b97661sm49794403eec.7.2026.07.14.08.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 08:16:20 -0700 (PDT) Date: Tue, 14 Jul 2026 08:16:16 -0700 From: Vishal Moola To: Kevin Brodsky Cc: linux-mm@kvack.org, Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Pasha Tatashin , Russell King , Catalin Marinas , Will Deacon , Ryan Roberts , linux-arm-kernel@lists.infradead.org, Huacai Chen , loongarch@lists.linux.dev, "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Gerald Schaefer , linux-s390@vger.kernel.org, "David S. Miller" , Andreas Larsson , sparclinux@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Ning Sun , x86@kernel.org, tboot-devel@lists.sourceforge.net, Ard Biesheuvel , Ilias Apalodimas , linux-efi@vger.kernel.org, Alistair Popple , "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: [PATCH 14/22] mm: set page table page type when allocated Message-ID: References: <20260714-remove_pgtable_cdtor-v1-0-44be8a7685d7@arm.com> <20260714-remove_pgtable_cdtor-v1-14-44be8a7685d7@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260714-remove_pgtable_cdtor-v1-14-44be8a7685d7@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260714_081623_123097_201A0E27 X-CRM114-Status: GOOD ( 28.20 ) X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+linux-um=archiver.kernel.org@lists.infradead.org On Tue, Jul 14, 2026 at 03:04:03PM +0100, Kevin Brodsky wrote: > As a step towards removing pagetable ctor/dtor calls for kernel > mm's, move the page type updates from the ctor/dtor to > pagetable_{alloc,free}. Thanks for doing this patchset. We should switch over from __folio_set_pgtable() to __SetPagePgtable() in this patch. Ptdescs and folios should be treated as distinctly independent of each other. Eventually, we want to replace the memcg accounting as well, but there's no existing API for that right now. Lets leave that as is for now; this patchset is big enough already ;) > __pagetable_ctor() is now empty so remove it; > pagetable_{pud,p4d,pgd}_ctor() will be removed at a later stage. > > The ctor is normally called after pagetable_alloc() (and dtor before > pagetable_free()) so this patch should have no functional effect in > most cases. Where calls to ctor/dtor are currently missing (e.g. > x86's split_large_page()), this patch will ensure the page type is > set correctly. > > This patch is based on Matthew's earlier implementation linked > below, with the difference that when freeing the page type is > cleared in __pagetable_free(), meaning that the update is delayed > until the pages are actually freed in the > CONFIG_ASYNC_KERNEL_PGTABLE_FREE case. This shouldn't matter in > practice. > > Suggested-by: "Matthew Wilcox (Oracle)" > Link: https://lore.kernel.org/r/20251113140448.1814860-4-willy@infradead.org > Signed-off-by: Kevin Brodsky > --- > include/linux/mm.h | 17 ++--------------- > 1 file changed, 2 insertions(+), 15 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 361a0d7b74c5..94f0fb1c662a 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -3684,6 +3684,7 @@ static inline struct ptdesc *pagetable_alloc_noprof(gfp_t gfp, unsigned int orde > if (!page) > return NULL; > > + __folio_set_pgtable(page_folio(page)); > lruvec_stat_add_folio(page_folio(page), NR_PAGETABLE); > > return page_ptdesc(page); > @@ -3694,6 +3695,7 @@ static inline void __pagetable_free(struct ptdesc *pt) > { > struct page *page = ptdesc_page(pt); > > + __folio_clear_pgtable(page_folio(page)); > lruvec_stat_sub_folio(page_folio(page), NR_PAGETABLE); > > __free_pages(page, compound_order(page)); > @@ -3799,19 +3801,9 @@ static inline bool ptlock_init(struct ptdesc *ptdesc) { return true; } > static inline void ptlock_free(struct ptdesc *ptdesc) {} > #endif /* defined(CONFIG_SPLIT_PTE_PTLOCKS) */ > > -static inline void __pagetable_ctor(struct ptdesc *ptdesc) > -{ > - struct folio *folio = ptdesc_folio(ptdesc); > - > - __folio_set_pgtable(folio); > -} > - > static inline void pagetable_dtor(struct ptdesc *ptdesc) > { > - struct folio *folio = ptdesc_folio(ptdesc); > - > ptlock_free(ptdesc); > - __folio_clear_pgtable(folio); > } > > static inline void pagetable_dtor_free(struct ptdesc *ptdesc) > @@ -3825,7 +3817,6 @@ static inline bool pagetable_pte_ctor(struct mm_struct *mm, > { > if (!mm_is_kernel(mm) && !ptlock_init(ptdesc)) > return false; > - __pagetable_ctor(ptdesc); > return true; > } > > @@ -3917,7 +3908,6 @@ static inline bool pagetable_pmd_ctor(struct mm_struct *mm, > if (!mm_is_kernel(mm) && !pmd_ptlock_init(ptdesc)) > return false; > ptdesc_pmd_pts_init(ptdesc); > - __pagetable_ctor(ptdesc); > return true; > } > > @@ -3942,17 +3932,14 @@ static inline spinlock_t *pud_lock(struct mm_struct *mm, pud_t *pud) > > static inline void pagetable_pud_ctor(struct ptdesc *ptdesc) > { > - __pagetable_ctor(ptdesc); > } > > static inline void pagetable_p4d_ctor(struct ptdesc *ptdesc) > { > - __pagetable_ctor(ptdesc); > } > > static inline void pagetable_pgd_ctor(struct ptdesc *ptdesc) > { > - __pagetable_ctor(ptdesc); > } > > extern void __init pagecache_init(void); > > -- > 2.51.2 > 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9DEB7C4450A for ; Tue, 14 Jul 2026 15:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yd0RifUXVkpdIQ36kyabqPvCqoCBwrxQx28KrfpC/34=; b=QuFPz9epdsKE26 1Z+aTeg2SPT8SRWEYzBA9UJH+R+kcQaGqLOz0+i9bXWsPpbF2VLi3gjw7ovfVbLZttrmnZbTwb4bg alh1yweex/scWGqGWtw0A0IWXEqBx+g+bjXSNRuDi8lRHYwE0f6nwlB/cBxdkmuHN7jeQ3i/kEuMa ymhglhKf8TmUbzTTfEK5IEycizfNDTHjLIV3pg3FWkmFnuW1lE9Nd7593H0kFN9OkjEAWDlH8e4Va xKYiJYi1+we8iu6XScsqCg7H3j97AenPoG2iU6QXPTY38aYKUUy/VAz1OQdYuab45eRDDSvNlHtRO 13CPQ8Yj91Vg9mjSMvUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wjery-0000000CV25-19mT; Tue, 14 Jul 2026 15:16:26 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wjerv-0000000CV09-0Ke7 for linux-riscv@lists.infradead.org; Tue, 14 Jul 2026 15:16:24 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-37e0a189b0bso997624a91.1 for ; Tue, 14 Jul 2026 08:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784042182; x=1784646982; darn=lists.infradead.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=fwuFYnIFntaeyFiFTCtuOmdD45sxN5bbxj7Gff2yTa4=; b=dCdZx7qm1qxuaTabdykrLmfoPr8SFCmMQAqkUv/TIvPwJbr2+nRRvEIGJ5fWjCWFNz J01hg1uSD2z7qzRuQhCXpaZqRSFmUhay9nvi0FLhD/IuaTGZ9t+R40rDliVQsVJVM06c 1t+aZeadSWGsP4bshY3onX5F7xO8jlr71GlndOzFvZN1cRmUGEHGjc3PZW4fykFr2Ryr Q4MRrQaPHt09lNwg5Vq1TynVi3HImWWb1rhRew0mvUmLbn3VzxGRd9FGtvXRnDdPLuwG J5KtWjPpdMoeWr/S211guGXVGGzq7U3LNVDEUQalIgKJiugChT6QndA7yC3sNe/PT0Jp b/2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784042182; x=1784646982; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=fwuFYnIFntaeyFiFTCtuOmdD45sxN5bbxj7Gff2yTa4=; b=GJV6lO4e2r1M/A7EyLihLcg4q45SZOz/uioOGd6oPDDf4d4nQ+q0LCnAdbqlo1mVrj PLx8ccTOVyVKaQpqJ6jL4EhnLvL2xgpbInmA5AZZoW6LDKcNMRW9kbhYk2jjxS5jynf0 Zc8hjovOoFxqL0DnZjgl9Gc6rekbYwUUXG5Bkx2hVZpElVlgx4uwNC/UI28XyoDcs1/Q 9szPdhcHh8ww9Yp1gl9I421y8xx8JByq6k0b7QxuTqr4fmov2UlFeRnu80tWzkj0qj9G XeKapUII3A3eKA5eTHuhSg4Q3cVakd0beHcvn8LA9rCCw44dZSZUf0fpVaqrvXL5QSxi B90Q== X-Forwarded-Encrypted: i=1; AHgh+RpxkvMpo9dEI6/9/NyLg5VF2ihkc9eMTdKv0azGYfbV952E4lhWTjHGXZ90NgiDtwI8XRGtc9qV+IpMzg==@lists.infradead.org X-Gm-Message-State: AOJu0YwAnFdlY1dvjthNEGdS68GrJI2wmdLEQwnx63J2tukHS+RTqDIM x1xGA+WAWdi6eaJBxNtBKiG95Z5bBJzWohCpujc7mNbN/s8dczDhyl5+ X-Gm-Gg: AfdE7cnNlMlLt/py1T8C/9PPGaK83irR0HWFYElq/9SWCzFSMM7OmDBMCAH08qvu5xy AQD3GAOGM6wKVB1FViTRftEovAiR9G6dFkkR772jY2pVzsDEyxGejuK//JdWooD7Ssqn+NevrP1 cOCJddXOZrAdRxgzr6s+7PZz3nVXHAWTWuNaoHtqVRHdcFoK+lDjcnKwHlkY+zwbvhMkhlWlAPk ArpbBcOQXI/t6fSrEuRSf8vS2lGmzZ7WVNMcl/NzJAnu8Xa5Qnk1nGEICd5ZYZh9A0O5kcLsoZm /5DfSmPPnLeOx1zshbnBFjdTyK8mIVqdwHoM7G4zMM7CVB4ASo7ZoEI+UgIDkHb15esErOXscz6 f02imMTyZS2bbrX51k3ABsTPL1M7ZyMuzpyXZT5xGx5xG9E5GP/aoO6o4pETkRHgiwhx38cGy6C 6/wyxf6gIO8yJHjWTNu7IxxyLuVBGN4IjRKmLb4OYV7uMD X-Received: by 2002:a17:90b:2e8f:b0:380:8b14:d8e1 with SMTP id 98e67ed59e1d1-38dc7b3f8ccmr13234040a91.24.1784042181685; Tue, 14 Jul 2026 08:16:21 -0700 (PDT) Received: from fedora ([2601:644:937c:6c90:6d4e:7b2d:4a39:fb0c]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-313b4b97661sm49794403eec.7.2026.07.14.08.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 08:16:20 -0700 (PDT) Date: Tue, 14 Jul 2026 08:16:16 -0700 From: Vishal Moola To: Kevin Brodsky Cc: linux-mm@kvack.org, Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Pasha Tatashin , Russell King , Catalin Marinas , Will Deacon , Ryan Roberts , linux-arm-kernel@lists.infradead.org, Huacai Chen , loongarch@lists.linux.dev, "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Gerald Schaefer , linux-s390@vger.kernel.org, "David S. Miller" , Andreas Larsson , sparclinux@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Ning Sun , x86@kernel.org, tboot-devel@lists.sourceforge.net, Ard Biesheuvel , Ilias Apalodimas , linux-efi@vger.kernel.org, Alistair Popple , "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: [PATCH 14/22] mm: set page table page type when allocated Message-ID: References: <20260714-remove_pgtable_cdtor-v1-0-44be8a7685d7@arm.com> <20260714-remove_pgtable_cdtor-v1-14-44be8a7685d7@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20260714-remove_pgtable_cdtor-v1-14-44be8a7685d7@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260714_081623_126434_1365BF32 X-CRM114-Status: GOOD ( 28.25 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Tue, Jul 14, 2026 at 03:04:03PM +0100, Kevin Brodsky wrote: > As a step towards removing pagetable ctor/dtor calls for kernel > mm's, move the page type updates from the ctor/dtor to > pagetable_{alloc,free}. Thanks for doing this patchset. We should switch over from __folio_set_pgtable() to __SetPagePgtable() in this patch. Ptdescs and folios should be treated as distinctly independent of each other. Eventually, we want to replace the memcg accounting as well, but there's no existing API for that right now. Lets leave that as is for now; this patchset is big enough already ;) > __pagetable_ctor() is now empty so remove it; > pagetable_{pud,p4d,pgd}_ctor() will be removed at a later stage. > > The ctor is normally called after pagetable_alloc() (and dtor before > pagetable_free()) so this patch should have no functional effect in > most cases. Where calls to ctor/dtor are currently missing (e.g. > x86's split_large_page()), this patch will ensure the page type is > set correctly. > > This patch is based on Matthew's earlier implementation linked > below, with the difference that when freeing the page type is > cleared in __pagetable_free(), meaning that the update is delayed > until the pages are actually freed in the > CONFIG_ASYNC_KERNEL_PGTABLE_FREE case. This shouldn't matter in > practice. > > Suggested-by: "Matthew Wilcox (Oracle)" > Link: https://lore.kernel.org/r/20251113140448.1814860-4-willy@infradead.org > Signed-off-by: Kevin Brodsky > --- > include/linux/mm.h | 17 ++--------------- > 1 file changed, 2 insertions(+), 15 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 361a0d7b74c5..94f0fb1c662a 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -3684,6 +3684,7 @@ static inline struct ptdesc *pagetable_alloc_noprof(gfp_t gfp, unsigned int orde > if (!page) > return NULL; > > + __folio_set_pgtable(page_folio(page)); > lruvec_stat_add_folio(page_folio(page), NR_PAGETABLE); > > return page_ptdesc(page); > @@ -3694,6 +3695,7 @@ static inline void __pagetable_free(struct ptdesc *pt) > { > struct page *page = ptdesc_page(pt); > > + __folio_clear_pgtable(page_folio(page)); > lruvec_stat_sub_folio(page_folio(page), NR_PAGETABLE); > > __free_pages(page, compound_order(page)); > @@ -3799,19 +3801,9 @@ static inline bool ptlock_init(struct ptdesc *ptdesc) { return true; } > static inline void ptlock_free(struct ptdesc *ptdesc) {} > #endif /* defined(CONFIG_SPLIT_PTE_PTLOCKS) */ > > -static inline void __pagetable_ctor(struct ptdesc *ptdesc) > -{ > - struct folio *folio = ptdesc_folio(ptdesc); > - > - __folio_set_pgtable(folio); > -} > - > static inline void pagetable_dtor(struct ptdesc *ptdesc) > { > - struct folio *folio = ptdesc_folio(ptdesc); > - > ptlock_free(ptdesc); > - __folio_clear_pgtable(folio); > } > > static inline void pagetable_dtor_free(struct ptdesc *ptdesc) > @@ -3825,7 +3817,6 @@ static inline bool pagetable_pte_ctor(struct mm_struct *mm, > { > if (!mm_is_kernel(mm) && !ptlock_init(ptdesc)) > return false; > - __pagetable_ctor(ptdesc); > return true; > } > > @@ -3917,7 +3908,6 @@ static inline bool pagetable_pmd_ctor(struct mm_struct *mm, > if (!mm_is_kernel(mm) && !pmd_ptlock_init(ptdesc)) > return false; > ptdesc_pmd_pts_init(ptdesc); > - __pagetable_ctor(ptdesc); > return true; > } > > @@ -3942,17 +3932,14 @@ static inline spinlock_t *pud_lock(struct mm_struct *mm, pud_t *pud) > > static inline void pagetable_pud_ctor(struct ptdesc *ptdesc) > { > - __pagetable_ctor(ptdesc); > } > > static inline void pagetable_p4d_ctor(struct ptdesc *ptdesc) > { > - __pagetable_ctor(ptdesc); > } > > static inline void pagetable_pgd_ctor(struct ptdesc *ptdesc) > { > - __pagetable_ctor(ptdesc); > } > > extern void __init pagecache_init(void); > > -- > 2.51.2 > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv