Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp5401786rdb; Sat, 30 Dec 2023 22:24:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2rduLQGo+OSTy07NlVHQ93Xstks7Otf6JVhfP7+BmWT8vxngJiRaiECWorz3zzIuj2r5M X-Received: by 2002:ac8:5787:0:b0:428:1be6:e1be with SMTP id v7-20020ac85787000000b004281be6e1bemr772052qta.77.1704003877156; Sat, 30 Dec 2023 22:24:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704003877; cv=none; d=google.com; s=arc-20160816; b=G4FSPTj6de3LVLuMTt3TuaphzO91QDG1XIrXr71T2qemLNpZJtJvVpi8AZ3AyKtf3/ r4szPXr+SXsfNjEhxox4GmPp6owl69f+kzGZLawNCH+KQ9bq1J5xtBIp/mJqEk3l24K6 nUEcIPFss3xB5M7iuR5MPWeA7Mj98/kKD24K+DKlFlwXZwxhiO7Ap26jy2raVPVzK+ra DHLDzOpjqYWPgx7KGu/ng0r3uKtFJBlk6lyVlTZOPo8O15v4vnyW3PEJn9kgImIpAB2r 1YHHQlZPPOHp/1DtaYWb6q2G+flIfL0ZFfUu4LXJzuAV24vBAqAbBm9KA1OwY34V/Vcu iY3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=5HQxn8vkoSUaqJUQWPI644Z3yn6AIK9AE++GM3uLR50=; fh=DrC11EGBAUqo91sbESjPcJV1gpWnPt8reyQoR9d6Q9Q=; b=BLjfMS+EO3BpIhWylYlK6zmcG2O0yrowlFNs33W1oSSf41FXThjki10xObjnux6pZR WRqwJqDmrgxBdk9dktIiv7Wsb/PGskocNmb+ciz8SBtEwjpVvvQn+KF7txXT2Tbsmr+P S2Y2lUaadtEzgMsTkMOz1Yo+DmSjccoLkcaYQnFq++21p3HzYYQtiRNIHra4P5bn+YFk 0fL1uvRGBNVScdnKDpiL2OXgBXFuWffBJ3UMXib2BKE5Uek5+qYkzgcniqadTrda8oNb SxCE7njJX313NONDCbtEWNiYqshgPd2Ey32PHmjf/JiIa3rM8cNK37IgLIvrNi1SRgZE twTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13643-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13643-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t20-20020a0ce2d4000000b0067f8dc03511si20698059qvl.80.2023.12.30.22.24.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Dec 2023 22:24:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13643-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13643-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13643-linux.lists.archive=gmail.com@vger.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 E3FAC1C21501 for ; Sun, 31 Dec 2023 06:24:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F10263C0A; Sun, 31 Dec 2023 06:24:28 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 AC87D33D1; Sun, 31 Dec 2023 06:24:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id 8DD381C0002; Sun, 31 Dec 2023 06:24:22 +0000 (UTC) Message-ID: Date: Sun, 31 Dec 2023 07:24:22 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/4] riscv: tlb: convert __p*d_free_tlb() to inline functions Content-Language: en-US To: Jisheng Zhang , 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 References: <20231219175046.2496-1-jszhang@kernel.org> <20231219175046.2496-3-jszhang@kernel.org> From: Alexandre Ghiti In-Reply-To: <20231219175046.2496-3-jszhang@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr On 19/12/2023 18:50, 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 */ You can add: Reviewed-by: Alexandre Ghiti Thanks, Alex