From patchwork Tue Dec 19 17:50:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13498798 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 A0951C46CA2 for ; Tue, 19 Dec 2023 18:03:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A25566B0078; Tue, 19 Dec 2023 13:03:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 97D058D0007; Tue, 19 Dec 2023 13:03:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68C4A6B0081; Tue, 19 Dec 2023 13:03:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 48BB88D0001 for ; Tue, 19 Dec 2023 13:03:31 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 15F381A0E4E for ; Tue, 19 Dec 2023 18:03:31 +0000 (UTC) X-FDA: 81584340222.29.DBD1A1E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 1A7981C002B for ; Tue, 19 Dec 2023 18:03:28 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qZeIMWFF; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of jszhang@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jszhang@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703009009; 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:dkim-signature; bh=ozqlHfd+iDCV8pBHY/VR7pPpuWXuYSgWYa3OF+jTDco=; b=XeOxFNsWbUg3NsJVSxiP1agQ8xIMDp9b68GJFsvLWpz5lxIEjZeSCZCva+k6GMk/eCcvrp /5sE5f3nn+KRpLZgMqWO9WODbPjN2DiG+7X9V+f/AF8wSM9jee412VEmpuvlInxKc08xRu QDjMuXz3T0cOpeXOVtjMgzZAxGe2PF4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qZeIMWFF; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of jszhang@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=jszhang@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703009009; a=rsa-sha256; cv=none; b=QwHBdjxJeTodTsggqq1ScMUUcWrwE719wofl2o0zLCz1PzrQ8MuDJ7mXzm8TbbL9bO+Cic 5qAe/9LGozK6rOGm8FNllkRwxRUHIRr3YPToN1vZ1z4sRHUPpNMB4ImPpdYhsXWWOrTM9l eIGhlXkFBAxHhyXDcl46ZhT6fgIXU0s= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 12B3B61472; Tue, 19 Dec 2023 18:03:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F40EC433CB; Tue, 19 Dec 2023 18:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703009007; bh=DsAEkljb9nELe7pOkNsFuedvY7TlIkqM0TVa9ONTLHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZeIMWFFttxnxsz70F8UouiwH0y4TqZqUR0au/SLYyPTk1mvMoENsBc4ab890iYVP BLByYZiQvFaJaD70giLF0L/HZSuSnQoA27jZ9O0sTHDMS+CV7k5vLv971aK+ISHT0h Q723BOdVl4693wzHnanJbWjMnp8eMfvvBuZL+MqIdTyv4cvHil7xR5nCM9zK5aZIBl duobbluzAihDUQKnsNK7gbSfhRYl4rIktzJyXgaa/afOM+eBTBTEvSSO+NmqV+Zt0X kyvovCVxXTiaOcuXTRROcZOvZHg5P/fqLv8479zyhTaEDOiXIlorhkYKPkcN5VeNZg uIXfSnq44E5/Q== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Will Deacon , "Aneesh Kumar K . V" , Andrew Morton , Nick Piggin , Peter Zijlstra Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/4] riscv: tlb: convert __p*d_free_tlb() to inline functions Date: Wed, 20 Dec 2023 01:50:44 +0800 Message-Id: <20231219175046.2496-3-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20231219175046.2496-1-jszhang@kernel.org> References: <20231219175046.2496-1-jszhang@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1A7981C002B X-Stat-Signature: ttftcr7zzdw3cjnr86kic7pmyn695bbp X-Rspam-User: X-HE-Tag: 1703009008-856630 X-HE-Meta: U2FsdGVkX1+gHLeHErnUms+UpvTeaskq9mSOVO5R9wxiOJRCI5f7/YLOwHJGWXqUC7mBXgkD+pQn0jnH19jfTWtqCCIEJVvqlNTCTjUJG2GRChRRwheUWvqKSC/0UYNELMN9QzxdWyE8FheIWjsZjyuu2v4ycmlvH8T92gbHg+8AI0cJ0oWcPhsuUT3eYzhHprmaF4lsfR3CQwLimztpGQtaSSewFwdtr4NErdBLWSTGGoOeEva3ciJdY6mv/fTpTIF10iwWYyr6+bG96mu567cDenI/ttf3u11JHveBsTILkh9xV2fH+TQtjrODLnHQXwPv68frBZ/oq5Aupbs3xUf+fJLhEEPwX2CHXj+jTwwXOhHppppmy6N0rIz3ITu4VsO6+K9voeZ8bMIWP/WrnQcP2zON0QcwNEug+U7urjUKAZHi1+Ueyp4pkBzFWKRGDMc5RFOlZQfTKv7SnxHCrXbv7mNPDDvjvMbGk96Ucv3c3GMMKm4/6CDt0k6UdpQRo6cnEQXTOcvcjAaD8ubSB75DegWNZlf0RlCzOodpAzPuM6yVjoUKWx8jw09dABqbbaI3INWP7x0BgdtQP8lkj8yAlilVjaUtggd4wU3VFnxBqqchAXoi/ZLApBTxizjVb7mLU4XGs3vuSvSx4HCl8c7uwWZDZQgH0JpmtwWaSgj9Cw/FU7UYK/ckNx1sYaB6h4pcNQwb0ujXZt21vbGS0qNp3canv6N+xy6DB8kiKuS8whUli1RlqspvlCM6M0sKYEZDzQESueU1RZ+Px0SsxXh35xWew+9WGSmkuM5g4hQHVMnzegw6pB2YORiRKLWcYrwqxS+g1q+ssMqEEXY0g4Pl92Cz02pkgfPYlgQleg93jbneARSXlmu3fz2rpgE7bU+WzI5GEGcomh+UlLvaRs+Fhh4EQmRplm1sI24LWlF+pYybtXkK6sfKcbGAwiiFs8RxmvhU3/gQXRLNiHL xVMIJ4gs vvT+MpT+ULkVVffXuhTvT6AHiUSsHnb58VHg6lzFWOL5BBOopHM8JnqmnPrOge8b1p5dqYeq8I2qWpopgJwToUyjIg0c2BIc37oI7aqn6uXblkyPlY4ytGfv8nRqKn1qxJgWHOTpyZaXq3CcgXQPZhWju1exg1FSzbcyyYk4COLQOt6NQapY/FjJe/1ndwjniLzM49+7PD61uLb9dJJKNiF0AsHBtm5rWpxx4dohemhiYacyiLKPEv0v+NhcmMo/VBIuF9NVSiSC7+q77Mq6JKfwmHahJy2Ya758Y 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: This is to prepare for enabling MMU_GATHER_RCU_TABLE_FREE. No functionality changes. Signed-off-by: Jisheng Zhang Reviewed-by: Alexandre Ghiti --- arch/riscv/include/asm/pgalloc.h | 54 +++++++++++++++++++------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h index a12fb83fa1f5..3c5e3bd15f46 100644 --- a/arch/riscv/include/asm/pgalloc.h +++ b/arch/riscv/include/asm/pgalloc.h @@ -95,13 +95,16 @@ static inline void pud_free(struct mm_struct *mm, pud_t *pud) __pud_free(mm, pud); } -#define __pud_free_tlb(tlb, pud, addr) \ -do { \ - if (pgtable_l4_enabled) { \ - pagetable_pud_dtor(virt_to_ptdesc(pud)); \ - tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(pud)); \ - } \ -} while (0) +static inline void __pud_free_tlb(struct mmu_gather *tlb, pud_t *pud, + unsigned long addr) +{ + if (pgtable_l4_enabled) { + struct ptdesc *ptdesc = virt_to_ptdesc(pud); + + pagetable_pud_dtor(ptdesc); + tlb_remove_page_ptdesc(tlb, ptdesc); + } +} #define p4d_alloc_one p4d_alloc_one static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr) @@ -130,11 +133,12 @@ static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d) __p4d_free(mm, p4d); } -#define __p4d_free_tlb(tlb, p4d, addr) \ -do { \ - if (pgtable_l5_enabled) \ - tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(p4d)); \ -} while (0) +static inline void __p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d, + unsigned long addr) +{ + if (pgtable_l5_enabled) + tlb_remove_page_ptdesc(tlb, virt_to_ptdesc(p4d)); +} #endif /* __PAGETABLE_PMD_FOLDED */ static inline void sync_kernel_mappings(pgd_t *pgd) @@ -159,19 +163,25 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm) #ifndef __PAGETABLE_PMD_FOLDED -#define __pmd_free_tlb(tlb, pmd, addr) \ -do { \ - pagetable_pmd_dtor(virt_to_ptdesc(pmd)); \ - tlb_remove_page_ptdesc((tlb), virt_to_ptdesc(pmd)); \ -} while (0) +static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd, + unsigned long addr) +{ + struct ptdesc *ptdesc = virt_to_ptdesc(pmd); + + pagetable_pmd_dtor(ptdesc); + tlb_remove_page_ptdesc(tlb, ptdesc); +} #endif /* __PAGETABLE_PMD_FOLDED */ -#define __pte_free_tlb(tlb, pte, buf) \ -do { \ - pagetable_pte_dtor(page_ptdesc(pte)); \ - tlb_remove_page_ptdesc((tlb), page_ptdesc(pte));\ -} while (0) +static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, + unsigned long addr) +{ + struct ptdesc *ptdesc = page_ptdesc(pte); + + pagetable_pte_dtor(ptdesc); + tlb_remove_page_ptdesc(tlb, ptdesc); +} #endif /* CONFIG_MMU */ #endif /* _ASM_RISCV_PGALLOC_H */