From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 960A838E8A1 for ; Mon, 20 Jul 2026 19:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784574319; cv=none; b=kuNE0UCCG5elZtCBUglUy6hflUaCcjiGKlM+0KiyHhgT5YxQQVz2Fc3/+j1Q8XxgBW90lbkvT6GgO7z9QFcgUanWwtMoXkh6Yrt8naUm9EAFAwFPlmN0B+iB5RbZTOAGqe78EvSIPZS0Q6EP758p1VtOEosQh9cKitbbRUWsjVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784574319; c=relaxed/simple; bh=fnW288skhTtWEbrTN/fD9Nt9dtFSRpG2InOVP3xSzZg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tq10+GNFV8NuIFOG3s/EwGy8MW7fk0GS46HbxIXTNPbKlctXl707rS7M18ZWTYlvq8aFTCtHvfqibWsrqfd6q9DgfwUOzsUR+WCyso1oU6I1YnC6jlXKfGtuBHpa6dw7CJt7abEY98VaGVaAPuIHoKZtXjxR794spugFjzhGytA= 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=NbyExw7C; arc=none smtp.client-ip=209.85.214.170 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="NbyExw7C" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2ceae1ed204so84113045ad.0 for ; Mon, 20 Jul 2026 12:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784574313; x=1785179113; 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=kPMaiKQm/Lrn2+15jJw1Tz84+egEdnjBHflNkHpDaxg=; b=NbyExw7CLFk71hAnpCJNUiZedvi+eDrJI9mqRpI89yk+kTVspS/t7ax2vHPuApaQI4 WjEB3dlDf7AbdioL0MPE36Jh2OhFkDOOWSQrFN49T1hqj3zWED3bPmdmyadRGmnbJo1E ca0paUja8vJl0Px2IaJ+jvDFtjbxKlFU5vZxK8Q3vOdXClzC4n6Czf1r4b6kVgsZv1yX 29P/R/8UZqC4oL081tJMc1zmK3K/Isg2hL9sbZjEOLbVukDq5XC/fATt/bIrIzRkK0rO TQ1jiAAqfSRYsE5Vtkbln/d/nZy4Gh4zYiqUXLwpTtl2Myfh1ggjrRZH6EwGYJPKSxwC jAWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784574313; x=1785179113; 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=kPMaiKQm/Lrn2+15jJw1Tz84+egEdnjBHflNkHpDaxg=; b=awD3ZzlPDGaoV58hFx0VVsZL016No/GZFT1JWvUuvlvGbcRjkQ/dfjXirK7lLFFEIs RDIyaW+iKaXD6p198lh0P5MuX8wuHqe6p1DRn+oWDAcRVV7WelQipXmdqOefPVhyRtjp MgtNQPW40a2GamdQEvPAJpqEoiOMnv2UrSwP7uX1APlqNNmB4J7FDpfRrii+Klhm/C6K Hv4ewAAYpxaZR82JE0cGfSjE7b390Ur+TdMATarX2Iex8tL+UYLxtSwS6Q4OqBA/7I7v Ub6T2lcHc1A24M0voWcLwlSIj4F8kP35Ai4bnXO3s6NbY7oRaag1sUoFIOZiWWAEJfcF SKRg== X-Forwarded-Encrypted: i=1; AHgh+RohLKnu2xk0IG856FwF0GtyKx68GStPypvktnVpWTlLfNzF3CWj+EgvL6I5DVf4ZrY1LPLi1SXRXH1Z@vger.kernel.org X-Gm-Message-State: AOJu0Ywb54lZ5a0uwn6FU88FFhtvkK4agJVmgMnsdwCqTc5gaaxnRFPE EGP8VuXBQEjdUnwEJ/1IIfAp/n+9clFU1QeYYm6NogO1WldzdkvnEBHd X-Gm-Gg: AR+sD12ggOeVlxQt+EZoqVfQDAIEpn60NGWHywWZFBfOIZ76EIhc12mQ5qcGHNAUP/E XLwane23pJyCjZpYRBiDlNy5ZIX78xRu5nD3q2hRu03MErDVmN78rhATMMLuZhsZwtJFdXKER0d 4mnQb7csJ931FImAdlljqb1TMoLGPnXxqd0TxBwOLu43ARgA1/oWOJ26FsOaKWCW+aq5FLI9/vh upg9MB1EQFXryU/Rw+yVc7YQYNDz9XIAVh5uXfdqoGG0+69xxPrMVRMb8BM5MFR2DwaMU/vkTEe 5wFmFmdOIQRaDMPTNvtnY10e0UOn4tUElWBiVnVMa6SDqHDKpT/hY4nx2j2U9C0ITmrRJdGYyqP s9TCL/OUh6YT0Zj9zyjOSa6+mq3bCfaYm63ZR5iheFlbnEXVQeQxJBsLxQPGqAUc4jS9g13EJeg kH22wAulpp6AGD+KbkZKjK/kzk8OotkZiu+A== X-Received: by 2002:a17:902:f681:b0:2ca:3e3f:4956 with SMTP id d9443c01a7336-2cf34a35445mr164591015ad.44.1784574312756; Mon, 20 Jul 2026 12:05:12 -0700 (PDT) Received: from fedora ([2601:644:937c:6c90:6d4e:7b2d:4a39:fb0c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cf3448f73esm60735085ad.16.2026.07.20.12.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 12:05:11 -0700 (PDT) Date: Mon, 20 Jul 2026 12:05:08 -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-arch@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: On Thu, Jul 16, 2026 at 11:49:31AM +0200, Kevin Brodsky wrote: > On 14/07/2026 17:16, Vishal Moola wrote: > > 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. > > Thanks for suggesting it :) It's turning out to be quite a bit more > involved than I expected though! (There are multiple cases where we call > the ctor/dtor without using pagetable_{alloc,free}, see my reply to the > cover letter.) > > > 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. > > I sure remember the previous discussion, but my reading of your comments > [1] is that we cannot really change this as long as pagetable_alloc() > can be called with order > 0, right? Multiple archs still rely on that. Kinda... The concern was about callers accessing tail pages directly for that information. Using the folio API ensures that we always look into the head page. Since we're now doing it at allocation time, we know we always have the head page, so it's fine. The dtor/free should be more questionable because the underlying api uses virt_to_page() which could look at a tail page... oopsie. I haven't seen any reports tied to it so its probably fine (the setting/clearing has been using the folio API since ptdescs). We can say thats a happy accident that makes distinguishing ptdescs and folios easier :) > > 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 ;) > > Yep, looks like there was an attempt to improve this but it had to be > reverted [2]. > > - Kevin > > [1] https://lore.kernel.org/all/aha321ndGSdReBJR@fedora/ > [2] > https://lore.kernel.org/all/20260225002434.2953895-1-axelrasmussen@google.com/ > 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 6253EC44520 for ; Mon, 20 Jul 2026 19:05:31 +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=nDlm/x12WO64MsoQZmt3vLUONdev6q4FTL6awEKRcKg=; b=lo6sfjkPmgt5ra tGjpm2E/nai0luhDG6aRoXOpyLCL4wPmFBW38i24xGknKO7n5OifwUM3h/sKQGI3jtMjKFOPyeaDh 0grxfzcI4gLy46UPTG256tghvVWI8GspJ9xwBihCtrYJHAImXfzLE+73671BoMl1sS5JamkZm2maA vbAQPS/mawbPCPj3yJ00HpWCdAkeG1VJjYWBeDZwYAv6j/QPHAX57jDRvTYwRHGZMQaVVcz8e4+IO epSaW3GMQEMweRlkUr3EJrqfKeqei5tV0hfV8tnCeVz+pr/XY9wqNaTsyhqgwAXpH6Aok8M8T2+su M237EqpRo+sPc0CCYdrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wltIk-00000007ikU-3OzR; Mon, 20 Jul 2026 19:05:18 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wltIg-00000007iiW-1yqe for linux-riscv@lists.infradead.org; Mon, 20 Jul 2026 19:05:17 +0000 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2ceed7018c8so46861565ad.1 for ; Mon, 20 Jul 2026 12:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784574313; x=1785179113; 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=kPMaiKQm/Lrn2+15jJw1Tz84+egEdnjBHflNkHpDaxg=; b=UBo88U6OuaWJQo6wbNNQ4fEK8ht2MGh+8erPQ84WnrqKZA+8H3CRCwDhlB62gTMYPY VOkNyFnTnSjyZvzIfhDtyUYbDXIJL5RSwrO+cpO+1EEGY8jGn7+Ti9sGZBNaD+v/ZHx1 DZY3j9t47Te9h/1khdN5HVZEfa0qWhe2xvQNIMzm+F+m07vOeISvMPMXqtstC8y4uLdQ pr8BK2AcQyjasdHbcmMyfQSDX4BVUViACqIlaqNA/5Z3gCk53obhll91zqr2rIj/8N5B oGGwE3GHlXgHbUp8WIPPi8qOOTqFmK7JUCCq7sN6nxpav8tuR9sDLrCzHmwCLY7UtExv /xwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784574313; x=1785179113; 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=kPMaiKQm/Lrn2+15jJw1Tz84+egEdnjBHflNkHpDaxg=; b=AV9wx6NsL3HYNUWCjRPJONkj2QV8ww+dCRs/LkJUlrMJoyTKDj/EQcS/lBywIrTBG5 cUED95s4s24o/ADguDSwJk2bh5udx0OEY2HHmsJKDorQuCGxwt/lfsAjrqW7Viz4Oinx p4yh7tZaNkllCTlUQMyrskJgrpGpGuQLL9kAD7lcS4XGHmmkvS6q7JmBFYrqoqtmGp6X /S/Wn9XwC5D2AGQPbPNR3ybUfvL1p4jS5G3wNPyVKj4DB1BBon4o6HK4+q+79PSyD2Ol 2F9DgV0wQRUC6jM8P+wY/IQZG4KjwKRYlw/yvfm3tA2dNkljZkesBliEyWM25NowEpJu UNAw== X-Forwarded-Encrypted: i=1; AHgh+RrzeYlFXnmu6C4c3aq9V0sE0LK3x3UJC7I8Rrxh1C5V3qmDO8TKcXf3hx96ho6hKFQoEI32RyZkc4MoMw==@lists.infradead.org X-Gm-Message-State: AOJu0Yz+RJlhIh6we3jGdrC2/+zTaL9g3NUc9VltuEFnVJNZsRWhWW4w 7iW0ECd2RaMMLg7B4QarI/pC8nqKpHZdgSwwprZ9GP2VnabOZJKlKrkW X-Gm-Gg: AR+sD10z+Rb8k3MZT+AzlKWXt+QxNI/hPDqRsNWw3+lx745lPtkfbLb5ju1Ojhu5rAO Sb56IXxeApmo3aDz5MK9u8K0Fj7vtD7FMxz1ulRJBqXIzAGK6dlZDa7+gfduyGVPJZcqwxVozMu nmhmWz2w4qcIhgNXCW+hjN/CoeFm99Z28y9JCmMMyjr5cmJuwkgZfIF1fBibcW8NI/5gsGyEXiZ dbmJJe32ZlcZ2rBF/4JbK7fMC0Gs/pZ+muw0JvWCr8T1C9Q6u6xffhJr3A+WAqBG/FT95yNPxyQ +U0AGT5nvt38UGLt6n6mcutR99B9zOX6QyHGAXmQd+Xf7h+9FUM/GmVCO1NHiufiKvYaSN8njw0 VS/BiCggLBSFp40kU6NylJp5ooMtRJxypFHEdM/0Diw9w516EBf9D3qElo/C8mHOsri/boKLpMo ouzHPgbmnGmwgf1b2jXpfLBBUbW/KY5GN90g== X-Received: by 2002:a17:902:f681:b0:2ca:3e3f:4956 with SMTP id d9443c01a7336-2cf34a35445mr164591015ad.44.1784574312756; Mon, 20 Jul 2026 12:05:12 -0700 (PDT) Received: from fedora ([2601:644:937c:6c90:6d4e:7b2d:4a39:fb0c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cf3448f73esm60735085ad.16.2026.07.20.12.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 12:05:11 -0700 (PDT) Date: Mon, 20 Jul 2026 12:05:08 -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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260720_120514_518105_56FF3FD7 X-CRM114-Status: GOOD ( 27.02 ) 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 Thu, Jul 16, 2026 at 11:49:31AM +0200, Kevin Brodsky wrote: > On 14/07/2026 17:16, Vishal Moola wrote: > > 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. > > Thanks for suggesting it :) It's turning out to be quite a bit more > involved than I expected though! (There are multiple cases where we call > the ctor/dtor without using pagetable_{alloc,free}, see my reply to the > cover letter.) > > > 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. > > I sure remember the previous discussion, but my reading of your comments > [1] is that we cannot really change this as long as pagetable_alloc() > can be called with order > 0, right? Multiple archs still rely on that. Kinda... The concern was about callers accessing tail pages directly for that information. Using the folio API ensures that we always look into the head page. Since we're now doing it at allocation time, we know we always have the head page, so it's fine. The dtor/free should be more questionable because the underlying api uses virt_to_page() which could look at a tail page... oopsie. I haven't seen any reports tied to it so its probably fine (the setting/clearing has been using the folio API since ptdescs). We can say thats a happy accident that makes distinguishing ptdescs and folios easier :) > > 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 ;) > > Yep, looks like there was an attempt to improve this but it had to be > reverted [2]. > > - Kevin > > [1] https://lore.kernel.org/all/aha321ndGSdReBJR@fedora/ > [2] > https://lore.kernel.org/all/20260225002434.2953895-1-axelrasmussen@google.com/ > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv