Received: by 2002:ac8:5349:0:b0:427:7d78:cd45 with SMTP id d9csp825269qto; Wed, 20 Dec 2023 05:10:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGutaWZvBNrnAllMd29eZx+p2rpJpzMDBuyxA+H6lhiyOyDLhop2MgTRJd6BejQnHy8R1Hb X-Received: by 2002:a0d:c907:0:b0:5d7:1941:3578 with SMTP id l7-20020a0dc907000000b005d719413578mr14633533ywd.95.1703077823302; Wed, 20 Dec 2023 05:10:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703077823; cv=none; d=google.com; s=arc-20160816; b=1B2SFpq9xNP+5v3ZyelWZ0omNI0S5auCSjd2huniE3wVSsmoHTiyHO+MHh75v0yvsK V8gCuOxBPIS46BoDKtL9WtfmN3rfGrNACT/yf26J19SQLLexADTvL8d0s2p6289Jc4Ez gE+uo9ogkxrT5xhmoEEjMwhSEgXYVLApQCHlxJJTIv2z80oBm76T96Jd8Q8YQYcRwQhm puHgnwJufEOAw8w2ubJnipndACqaHQ4x3QnUZpfqi7JEqP8UNh+6Ye79iTSkgfvxNhkK Hz6+qtU0GxoZ2AkD+I6fyEpzChJZ+fWo3wqVN9hsDS7TWYvusNflniRpykUrFg3I5N2I 9VWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FTZS4YBaJ+PLI1G+1Lqx3Cjaa9VsIGCr/mf0fz2eOeg=; fh=1+KyrSEYdUydde6aiAgTuzPI58xgJq87WwMEXIm/JR8=; b=JodZXqgleSKPLGHDLtHOE8owmYZtrjOke3QJ5eEk4jngP9nQE/big2OAgLcBw510nn wTWWhT8NgzjqY9VJcUaT4zsez0fqEyifMbcnIpRdSk5Fta5EdvgZH/1u262fknXrW8u0 d5sFhD8b0Go6x0TmUmlxNYoHY2PCH5KK65yiQpLCi0DNL4Oaf/WttD9AsP13Fxj2WiwB uNfKK4mOOC3dwonsPr43iDG86OU8yXe3YDiZGjqVjzTtogsxH9neJYJT4kkXP0WCZ5eo ao8lmV7kY4MKUJaG+IOERfDB2oSA5KZYlwtuPhzFh1FqVkGh6sxgYAfZbq3KG6jjbzCe 8ORQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=geH8Po+2; spf=pass (google.com: domain of linux-kernel+bounces-6940-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6940-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id je10-20020a056102178a00b0046693993258si1087591vsb.604.2023.12.20.05.10.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:10:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6940-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=geH8Po+2; spf=pass (google.com: domain of linux-kernel+bounces-6940-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6940-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 219F11C2251F for ; Wed, 20 Dec 2023 13:10:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F38F358B2; Wed, 20 Dec 2023 13:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="geH8Po+2" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E93934540; Wed, 20 Dec 2023 13:09:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19026C433C7; Wed, 20 Dec 2023 13:09:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703077797; bh=kNBcPwaMlCBZq05QdM/ZhosCOAELdn7NQH61Zm2JFdI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=geH8Po+2xTzfgztalOer3avEmmYlxn/45tUCRRhRPkul1OdegcfPNbzZr3tlUU9gL Gr9cAMJrqZuYg4ZXywlT8vSMjii9EQa5EbRzNrvsitbUMRrwbGZ+Vs5h7oma4+HXCX Y6lx9NhOjzB4pblu7fVu8HdFsBrqgIGPmNWbmGUcFzrh5wBtM9iKG3YDgpGMKzvzlh 8vB2ywPk0x3h2DIr7Fq1JC41iWIBZuH9vX9FxlyK05Uq+uzcK1I4v29L51UH7MToRn KnLrmtlosx1RWynwXEXaab9s09kXI2/VKwn3Z8VcssHKf3wD1CPcmCmEDqkbqzUfsQ heTJfZCiYSM3Q== Date: Wed, 20 Dec 2023 20:57:20 +0800 From: Jisheng Zhang To: yunhui cui Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Will Deacon , "Aneesh Kumar K . V" , Andrew Morton , Nick Piggin , Peter Zijlstra , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Subject: Re: [External] [PATCH 2/4] riscv: tlb: convert __p*d_free_tlb() to inline functions Message-ID: References: <20231219175046.2496-1-jszhang@kernel.org> <20231219175046.2496-3-jszhang@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Dec 20, 2023 at 10:59:22AM +0800, yunhui cui wrote: > Hi Jisheng, Hi, > > On Wed, Dec 20, 2023 at 2:04 AM Jisheng Zhang wrote: > > > > This is to prepare for enabling MMU_GATHER_RCU_TABLE_FREE. > > No functionality changes. > > > > Signed-off-by: Jisheng Zhang > > --- > > 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 */ > > -- > > 2.40.0 > > > > Why is it necessary to convert to inline functions? Hmm, it's not necessary but a plus, the inline version's readability and maintainability is better than macros Regards