From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FAB0481FC2 for ; Tue, 14 Jul 2026 15:16:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784042185; cv=none; b=UBWImwTbzFBc4jhtV/4OGoCbQ0EeTDTefBE+E8WSALDfRBHnZGoUwcrZoHfy2oU1xXzzyCaNwKrWJpeoWQ2g/Igas0HuDfxjaDAF+dE0Xvkano5IayA/ntQ+UWcQtsXPjTFotreerTCmOtExcLv4gG1EDnmcp8OSyxV3CjcilMk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784042185; c=relaxed/simple; bh=b+EJlyZCjRd+zn9R4Sh1X4jRP+azN9ASK6QXE0fMCOg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ot6xnDpuUv7cSwc5jbopNW+7poArwPqc3c5ARQWDK8tTAbnekeIzkNdrHldA58ZSrZGhKtsuAo7jS0r5F8RXyQ9zRPUlUzz85PLWWf6haUjpGg2N7soTfOhN+KVo6KVAkyDUVJBZb1dCN91n632e02rrN9SKSvKgrxRErbMkU1o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KPPAUCP4; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KPPAUCP4" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-38de840f2f0so1170044a91.0 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=vger.kernel.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=KPPAUCP4LIdjO5XJ0zjy2zAJBq10fBFDDwlJY9GTpiAxYnLIYddoRSL3J3DqiV2P6y +ku+Y5iejEVZh74yQXu/qXHGwYG5tW7DUPanHDeomUKhLvdQ9xVYaRVbrSddbLJOI0ad Qa3CN2PzZmtaETC8zO5yZkKtPICmsqoVsAjJTpPBDiVw91s3T/y1PMupM2jzbtWqABLc vuMkMEHNPjyjGBPp96D51ljj1HiXb5xNpmWEkTe5pRWRrWkxeNs3m/dCydtAoDLnHP6C yMrnw4pGDOFin2LSg/EILdO6tpkQIxtwxT8Aq/YMZplq4BBxszdXGzHEbNOqUuiMfQt6 xyWA== 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=iTjBKXxtqPcc8bAf3pG6P5xh0AkffFgFcMJkAPsk3GSoSa3dT6CTA7qT2hjZtzEBUW xetBateZap87+ngL0wBTcj1IjTaVljrp18TurOyvZJat1ghZOE1pyvDP6cZ1+rA2xZ4W 8A81sXOxcgdtwS8C3t5R5Q7qId7xQJ9gahTfaFnlVFwNhXv9EoB4yLXKUBaE4mLhZFxU WJMyfz5oLEvOtFUffZ4UtC3UE/qP+/XXGoKxWqi4s51eSUiQeFCZqiGy+AYeTqlURkz6 AAnNYmHXkCFwcOI069/0glbDo+pGZ6HP0PJRucw1FndbdEmavqXcDkCBEOeqYHw2iGDn iCmg== X-Forwarded-Encrypted: i=1; AHgh+RqaF18KvoMYfeMu/wYVxnrGeNcCJ3ca3lZYFFXKEvDCBzf7Nsv1YGIKtvRg7n8J+CFHwS48vjAFPuQSZc0=@vger.kernel.org X-Gm-Message-State: AOJu0Yzw5L6H/LvfftGb4iRFl4xVdyTDXuvlZ3DvLkOrkUZHdzuVgwEt 7JZ21aGei33BJ3o6s8YH6x2Sw8Ql23BhGMHGzip+ZRajT6raN7tXq4qa X-Gm-Gg: AfdE7cm7vHiq6OlCEd1a/Sy2r04HPcOwax3bNe0srOf1rdX7XSYLP7RMvnSLOP5sOcl U2FDaAqzbPe4GAghI5/idPOBCRoPrybCIvU22UtI20Cu/9FQjkZbfjmM7GDV0GbBUEv1BoRF/RT iiWb+C7iVTe4kR62txjvXpx4YlAXhgPq1zOSoZsawrpgAsuKIr75fO/CqGr1VJfXutP+BhlX+PU IUZL2yCVInUYU7ry75iVwuCDYsnwCg34VkDJ9UqAhFyONelQ+MPM3MwlHzmLPxxKE3NyAw1XH3/ MkMRhi2Hq9k2BPA+abXn39a9yJjybItd+En15xr3P6IO6Q/p/v5HhYKXHnlCvxnNWiDOFURaZ8/ B7gZ870wICW3rgkDFF5rEp8dwZs6Fi9m7msU+tqv2wcbH3ND1a4eMSwlbLbysirPAYqtSO9Xrxp OCTLVjr83AbhA4GLh1hBqh5W8kTfO8w3LT7dTThkgKEUpK 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> Precedence: bulk X-Mailing-List: linux-parisc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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> 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 >