From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA07735E1CB; Fri, 24 Jul 2026 16:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784910355; cv=none; b=nAGXxLT8oma0LTM7ZW02FVFXX2lgEqFPgnbpUn45tIy35AdaOwqjriDm8TS3uWjkCjSHos0wJvXyvlL2hSoTx+SaQi4pLLIltbUYDteqfq+yN53MydgJSsXZHWsgtTDmR53+0IweKKCw6plZGnjV1ErcwtqYnYEw2RmXlGSetz0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784910355; c=relaxed/simple; bh=90PjtwWiYZulmqV39H8fGSHBZ8shBRidW6H3XBOLz1E=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nEhHnrUil7TmNinULKm+lMp1dPRJTVK/XeVtjnLczLfyowPBsf/KDeKOd0lJSHkFUtXRGnZyGxBUj1D4giofGTB8txBQR44G8+KnU9yc76hvzlZOIsDaq39ioySlyIDYxCpBjdySf77Z6e/lXdd3I5kCE19vuLg3OkxVBzmKdpU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=LSeaOheA; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="LSeaOheA" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 66C911655; Fri, 24 Jul 2026 09:25:48 -0700 (PDT) Received: from [10.57.0.90] (unknown [10.57.0.90]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D9153F66F; Fri, 24 Jul 2026 09:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784910352; bh=90PjtwWiYZulmqV39H8fGSHBZ8shBRidW6H3XBOLz1E=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=LSeaOheALTDiD44xvkD55jNPMvVMiWCKhoAY3QOMhLgjHKQ4vGk/sCbVALnk8LQcs UGzo+QT8sgIjgylea7jT8NDptv0jyxQHH1Yl0mF7+8llAZ/r++VL9OJQZ9z7INpPWZ IvaE6ewh0IBZMWQRx7oS05rwa6Tfr8Ub24gxyRR8= Message-ID: <13be2648-f68d-46ae-ae8a-5ca9e067cc90@arm.com> Date: Fri, 24 Jul 2026 18:25:35 +0200 Precedence: bulk X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 15/22] mm: only initialise pt_share_count for user pgtables To: "David Hildenbrand (Arm)" , linux-mm@kvack.org Cc: Andrew Morton , 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, Vishal Moola , Alistair Popple , "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org References: <20260714-remove_pgtable_cdtor-v1-0-44be8a7685d7@arm.com> <20260714-remove_pgtable_cdtor-v1-15-44be8a7685d7@arm.com> From: Kevin Brodsky Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 21/07/2026 17:12, David Hildenbrand (Arm) wrote: > On 7/14/26 16:04, Kevin Brodsky wrote: >> ptdesc_pmd_pts_init() initialises the pt_share_count ptdesc field. >> That field is only used for hugetlb tracking purposes, so there is >> no need to initialise it for kernel page tables. Skip the call for >> kernel page tables, like pmd_ptlock_init(). >> >> From now on pagetable_*_ctor() and pagetable_dtor() do nothing for >> kernel page tables. >> >> Signed-off-by: Kevin Brodsky >> --- >> include/linux/mm.h | 9 ++++++--- >> 1 file changed, 6 insertions(+), 3 deletions(-) >> >> diff --git a/include/linux/mm.h b/include/linux/mm.h >> index 94f0fb1c662a..b217ccbed5a3 100644 >> --- a/include/linux/mm.h >> +++ b/include/linux/mm.h >> @@ -3905,9 +3905,12 @@ static inline spinlock_t *pmd_lock(struct mm_struct *mm, pmd_t *pmd) >> static inline bool pagetable_pmd_ctor(struct mm_struct *mm, >> struct ptdesc *ptdesc) >> { >> - if (!mm_is_kernel(mm) && !pmd_ptlock_init(ptdesc)) >> - return false; >> - ptdesc_pmd_pts_init(ptdesc); >> + if (!mm_is_kernel(mm)) { >> + if (!pmd_ptlock_init(ptdesc)) >> + return false; >> + ptdesc_pmd_pts_init(ptdesc); >> + } >> + > I'd have said "the initialization is cheap, why bother", but we already do have > the mm_is_kernel() check in place, so This isn't mainly about the overhead, but rather the fact that from here on the ctor/dtor do nothing for kernel page tables. Patch 20-22 rely on this, and in part 2 I would go further and only ever call the ctor/dtor for user page tables, so that the mm_is_kernel() check can be dropped. > Acked-by: David Hildenbrand (Arm) Thanks for the reviews! - Kevin 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 2E577C53200 for ; Fri, 24 Jul 2026 16:26:07 +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:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kSi110OSceQKoJ0v7NgpRWGwhJ8KkiEvPk+TTM0M5Bs=; b=F1zLbRlui7/Eir Od0tDnw0PePhs3bkGZkBgEyGnwOFkCHgyS2TEIWDngXwhc6d/mZ4dLd5rj2hJi0nsYWkQ5867IKgw xG4Zmt3DQJxdUEmcsg/3FP+FYoGaBfDWtekhA6YZi+/9rmXal5SHMCyC4vDFiBlLEqGRsMZcG7X88 Q/tve4fR/yCvITcmytLSzXRtG+/AcZiHkDU5eOy7Qb289rO2lmvdpOP4SG1oUx9+cCbdxiXNmHrIX E4sJ6v/+E6+AX0Q1fUFtcpvSDmP0NhZG+fvPKtmnGk7dNcANg4RKrllcd9WtHb0nPutHLM64bH6lu nvKZdh4sqgcSqFwMgSPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wnIij-0000000Gq9P-3KiW; Fri, 24 Jul 2026 16:25:57 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wnIig-0000000Gq8j-1OUF; Fri, 24 Jul 2026 16:25:55 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 820DC1BB0; Fri, 24 Jul 2026 09:25:48 -0700 (PDT) Received: from [10.57.0.90] (unknown [10.57.0.90]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D9153F66F; Fri, 24 Jul 2026 09:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784910352; bh=90PjtwWiYZulmqV39H8fGSHBZ8shBRidW6H3XBOLz1E=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=LSeaOheALTDiD44xvkD55jNPMvVMiWCKhoAY3QOMhLgjHKQ4vGk/sCbVALnk8LQcs UGzo+QT8sgIjgylea7jT8NDptv0jyxQHH1Yl0mF7+8llAZ/r++VL9OJQZ9z7INpPWZ IvaE6ewh0IBZMWQRx7oS05rwa6Tfr8Ub24gxyRR8= Message-ID: <13be2648-f68d-46ae-ae8a-5ca9e067cc90@arm.com> Date: Fri, 24 Jul 2026 18:25:35 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 15/22] mm: only initialise pt_share_count for user pgtables To: "David Hildenbrand (Arm)" , linux-mm@kvack.org Cc: Andrew Morton , 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, Vishal Moola , Alistair Popple , "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org References: <20260714-remove_pgtable_cdtor-v1-0-44be8a7685d7@arm.com> <20260714-remove_pgtable_cdtor-v1-15-44be8a7685d7@arm.com> From: Kevin Brodsky Content-Language: en-GB In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260724_092554_531939_07A8B1D1 X-CRM114-Status: GOOD ( 17.09 ) 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 21/07/2026 17:12, David Hildenbrand (Arm) wrote: > On 7/14/26 16:04, Kevin Brodsky wrote: >> ptdesc_pmd_pts_init() initialises the pt_share_count ptdesc field. >> That field is only used for hugetlb tracking purposes, so there is >> no need to initialise it for kernel page tables. Skip the call for >> kernel page tables, like pmd_ptlock_init(). >> >> From now on pagetable_*_ctor() and pagetable_dtor() do nothing for >> kernel page tables. >> >> Signed-off-by: Kevin Brodsky >> --- >> include/linux/mm.h | 9 ++++++--- >> 1 file changed, 6 insertions(+), 3 deletions(-) >> >> diff --git a/include/linux/mm.h b/include/linux/mm.h >> index 94f0fb1c662a..b217ccbed5a3 100644 >> --- a/include/linux/mm.h >> +++ b/include/linux/mm.h >> @@ -3905,9 +3905,12 @@ static inline spinlock_t *pmd_lock(struct mm_struct *mm, pmd_t *pmd) >> static inline bool pagetable_pmd_ctor(struct mm_struct *mm, >> struct ptdesc *ptdesc) >> { >> - if (!mm_is_kernel(mm) && !pmd_ptlock_init(ptdesc)) >> - return false; >> - ptdesc_pmd_pts_init(ptdesc); >> + if (!mm_is_kernel(mm)) { >> + if (!pmd_ptlock_init(ptdesc)) >> + return false; >> + ptdesc_pmd_pts_init(ptdesc); >> + } >> + > I'd have said "the initialization is cheap, why bother", but we already do have > the mm_is_kernel() check in place, so This isn't mainly about the overhead, but rather the fact that from here on the ctor/dtor do nothing for kernel page tables. Patch 20-22 rely on this, and in part 2 I would go further and only ever call the ctor/dtor for user page tables, so that the mm_is_kernel() check can be dropped. > Acked-by: David Hildenbrand (Arm) Thanks for the reviews! - Kevin _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv