From patchwork Thu Dec 19 16:44:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Brodsky X-Patchwork-Id: 13915292 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CFA5E77184 for ; Thu, 19 Dec 2024 16:46:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFEF86B007B; Thu, 19 Dec 2024 11:46:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D87B36B0098; Thu, 19 Dec 2024 11:46:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C29016B0099; Thu, 19 Dec 2024 11:46:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A27BF6B007B for ; Thu, 19 Dec 2024 11:46:34 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 550D5A17DD for ; Thu, 19 Dec 2024 16:46:34 +0000 (UTC) X-FDA: 82912286814.14.7A5EF0B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf10.hostedemail.com (Postfix) with ESMTP id 453F4C0014 for ; Thu, 19 Dec 2024 16:46:18 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf10.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734626777; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lZA9kLthfPyIxwHp01Yxv5Ht/fhkFKG3TTGvCJtNyWQ=; b=TLORXml9Dl6Kh9L7qN+S2jKCLJIWQfY9vXpB8xtnoC1FUhgeazziUaxUn/AuHL+btO8A8x lqEhInV2N8M+2/kU965AmwIp4JRqzndCTqRfTCpgHc8G+dLE+QRimusV2eP8Htj19EZSwV 0H4idNIR4Eo+Eb1PGDqfvFaLO62++y0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734626777; a=rsa-sha256; cv=none; b=EblwEsIRGJ20MlMbQ1wCeQtLmxwhFBudz5TVurZkPbkJBPNAhfKS4nEqUdavRRrfvFb5cf eZj3UVPpWUZ271o89ZFXqudsRcy+8vfZ0dVaeJua0cBsaN3k7UePgKLJFvZhALwSVJXjCZ 7xyS2ACmGU5XSxgqGt7CUTOR4oDWKGA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf10.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com 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 2A70A1480; Thu, 19 Dec 2024 08:47:00 -0800 (PST) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2B9613F58B; Thu, 19 Dec 2024 08:46:28 -0800 (PST) From: Kevin Brodsky To: linux-mm@kvack.org Cc: Kevin Brodsky , Andrew Morton , Catalin Marinas , Dave Hansen , Linus Walleij , Andy Lutomirski , Peter Zijlstra , "Mike Rapoport (IBM)" , Ryan Roberts , Thomas Gleixner , Will Deacon , Matthew Wilcox , linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-um@lists.infradead.org, loongarch@lists.linux.dev, x86@kernel.org Subject: [PATCH 05/10] riscv: mm: Skip pgtable level check in {pud,p4d}_alloc_one Date: Thu, 19 Dec 2024 16:44:20 +0000 Message-ID: <20241219164425.2277022-6-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241219164425.2277022-1-kevin.brodsky@arm.com> References: <20241219164425.2277022-1-kevin.brodsky@arm.com> MIME-Version: 1.0 X-Stat-Signature: azr88tpu46u4szhpfn44zi7rgjzct3pm X-Rspamd-Queue-Id: 453F4C0014 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734626778-299104 X-HE-Meta: U2FsdGVkX1/Wx9Sx8hZtow3XMRhnH/uAbBEuFeNOaRkY2drkTYsY1G1K5hGfv3NdieyOVxS81pz/6JwadeErmWcmPrrtbtLIj5I9A9hTjESMRPw47xlT1yH9oRlk00lz5ZcdtXG8NJ/ybKI25j257Vj5EWX78UPPDXEa6l7L0mA1bFDNC3H9BTnNQLNc1HGw839DJ2IHIYYDUJK3KH6uWNtIMEI1NC7Y85HoXHhbpd8pHL6YNTJAq8tqWpKzt2kMtObvGK85wczJBaKh3j2oeobMzB61WCZwGWvwgnBn3XhUxwwWLEfuIseRA6HUnEkdQ0ZpH7skBPtH1GnfAxnTxkroueaWxg7HuZekPweiqEcJE0jLdrqgSyYYgO1NkSQlAgIAfmUo7yp4IYAO11ZHfhsmS7HXQTZKDvFZl/shzThQ33COd6dKONHAt+0sy27Zt3LthhIcImmLfzxf3CeLVV3QXEfWM/gxy7SJHU50rwDFSyu457h6DX2c+bxfi+wmtSZVz63uqnWOoU5VrpMO7+Mi3CL58R1fbesEwseCygilSHg6xr0CfiqnkzUor3z3RQiiA5Th3kdJpUZ5Df6UFOSNlpKDJLNweoLobW1L93miG/uzWSfE9cMvnOPd7W91nemk2R2TprhFsNGZWApcafgaq67GHznPyRml6NjHcPcH3boLWhoVHMsdvVKFyQL+7InYn/fJ5cRhjXJng051d0HyF2ICDsJGhFUT1fkKu4HEwPLayN+zWNtn1EFXrUdAVFbYx2Leh7zY1nY8OWOLlcBQJoYvDllteeVI8vSw8RO7csQUa7IDWdcO/Yqtwzqpqxo7hSnnKj8EPp3Uh6iselFOgIXdVvVVG8NzTitF3qKcIiEQDsykRH/nJjDE6RpKGN9tkAYyM7XDRu+UWCXdw3qFmFDziA7Fk1tvPxdOs95E9n7kHPt5dYPk+GrpUw5OgjPduL6b7h+2CX9ZVFT Rsf4V4ZD ihtGSs54h9JO+Iv2dIEIJfnx81lP+Wkmnd+klvHqwmeD2o4+XIfVftBwm4ihMYXYgoRBTK33kRu+8aSf8pw17V8ES4DUObrqmyWUI8BVau14WtezfsrjiZFj4faeBQ05y2OtO/WqzX1ll2RdFkcisPd/IWO6IQclwuzCxCwPn+ssW+mVtrfHAUQCCHnTCP0DvFMRf98WsJSYG8iQphgow5hokr7RAqHRnqb7pMt0iW9Wu2FmfCWKW7JlfaeBs5uieH25tdX4TrLH2xoarYO1ZnzTr587VKkDNQuTT4CcZj+C8na2yYCD2yjyd388DWMDPScDFkIruOdpNbjY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: {pmd,pud,p4d}_alloc_one() is never called if the corresponding page table level is folded, as {pmd,pud,p4d}_alloc() already does the required check. We can therefore remove the runtime page table level checks in {pud,p4d}_alloc_one. The PUD helper becomes equivalent to the generic version, so we remove it altogether. This is consistent with the way arm64 and x86 handle this situation (runtime check in p4d_free() only). Signed-off-by: Kevin Brodsky --- arch/riscv/include/asm/pgalloc.h | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h index f52264304f77..8ad0bbe838a2 100644 --- a/arch/riscv/include/asm/pgalloc.h +++ b/arch/riscv/include/asm/pgalloc.h @@ -12,7 +12,6 @@ #include #ifdef CONFIG_MMU -#define __HAVE_ARCH_PUD_ALLOC_ONE #define __HAVE_ARCH_PUD_FREE #include @@ -88,15 +87,6 @@ static inline void pgd_populate_safe(struct mm_struct *mm, pgd_t *pgd, } } -#define pud_alloc_one pud_alloc_one -static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) -{ - if (pgtable_l4_enabled) - return __pud_alloc_one(mm, addr); - - return NULL; -} - #define pud_free pud_free static inline void pud_free(struct mm_struct *mm, pud_t *pud) { @@ -118,15 +108,11 @@ static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, #define p4d_alloc_one p4d_alloc_one static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr) { - if (pgtable_l5_enabled) { - gfp_t gfp = GFP_PGTABLE_USER; - - if (mm == &init_mm) - gfp = GFP_PGTABLE_KERNEL; - return (p4d_t *)get_zeroed_page(gfp); - } + gfp_t gfp = GFP_PGTABLE_USER; - return NULL; + if (mm == &init_mm) + gfp = GFP_PGTABLE_KERNEL; + return (p4d_t *)get_zeroed_page(gfp); } static inline void __p4d_free(struct mm_struct *mm, p4d_t *p4d)