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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 2E8F4C48297 for ; Mon, 12 Feb 2024 14:12:02 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TYRGm5lnwz3cWB for ; Tue, 13 Feb 2024 01:12:00 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=arm.com (client-ip=217.140.110.172; helo=foss.arm.com; envelope-from=ryan.roberts@arm.com; receiver=lists.ozlabs.org) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lists.ozlabs.org (Postfix) with ESMTP id 4TYRGJ4zf8z2y1Y for ; Tue, 13 Feb 2024 01:11:34 +1100 (AEDT) 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 16DF8DA7; Mon, 12 Feb 2024 06:11:43 -0800 (PST) Received: from [10.57.78.115] (unknown [10.57.78.115]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8A1673F7BD; Mon, 12 Feb 2024 06:10:57 -0800 (PST) Message-ID: Date: Mon, 12 Feb 2024 14:10:55 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 03/25] mm: Make pte_next_pfn() a wrapper around pte_advance_pfn() Content-Language: en-GB To: David Hildenbrand , Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , Mark Rutland , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" References: <20240202080756.1453939-1-ryan.roberts@arm.com> <20240202080756.1453939-4-ryan.roberts@arm.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mm@kvack.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 12/02/2024 12:14, David Hildenbrand wrote: > On 02.02.24 09:07, Ryan Roberts wrote: >> The goal is to be able to advance a PTE by an arbitrary number of PFNs. >> So introduce a new API that takes a nr param. >> >> We are going to remove pte_next_pfn() and replace it with >> pte_advance_pfn(). As a first step, implement pte_next_pfn() as a >> wrapper around pte_advance_pfn() so that we can incrementally switch the >> architectures over. Once all arches are moved over, we will change all >> the core-mm callers to call pte_advance_pfn() directly and remove the >> wrapper. >> >> Signed-off-by: Ryan Roberts >> --- >>   include/linux/pgtable.h | 8 +++++++- >>   1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h >> index 5e7eaf8f2b97..815d92dcb96b 100644 >> --- a/include/linux/pgtable.h >> +++ b/include/linux/pgtable.h >> @@ -214,9 +214,15 @@ static inline int pmd_dirty(pmd_t pmd) >>       #ifndef pte_next_pfn >> +#ifndef pte_advance_pfn >> +static inline pte_t pte_advance_pfn(pte_t pte, unsigned long nr) >> +{ >> +    return __pte(pte_val(pte) + (nr << PFN_PTE_SHIFT)); >> +} >> +#endif >>   static inline pte_t pte_next_pfn(pte_t pte) >>   { >> -    return __pte(pte_val(pte) + (1UL << PFN_PTE_SHIFT)); >> +    return pte_advance_pfn(pte, 1); >>   } >>   #endif >>   > > I do wonder if we simply want to leave pte_next_pfn() around? Especially patch > #4, #6 don't really benefit from the change? So are the other set_ptes() > implementations. > > That is, only convert all pte_next_pfn()->pte_advance_pfn(), and leave a > pte_next_pfn() macro in place. > > Any downsides to that? The downside is just having multiple functions that effectively do the same thing. Personally I think its cleaner and easier to understand the code with just one generic function which we pass 1 to it where we only want to advance by 1. In the end, there are only a couple of places where pte_advance_pfn(1) is used, so doesn't really seem valuable to me to maintain a specialization. Unless you feel strongly that we need to keep pte_next_pfn() then I'd prefer to leave it as I've done in this series. > This patch here would become: > > #ifndef pte_advance_pfn > static inline pte_t pte_advance_pfn(pte_t pte, unsigned long nr) > { >     return __pte(pte_val(pte) + (nr << PFN_PTE_SHIFT)); > } > #endif > > #ifndef pte_next_pfn > #define pte_next_pfn(pte) pte_advance_pfn(pte, 1) > #endif > > As you convert the three arches, make them define pte_advance_pfn and udnefine > pte_next_pfn. in the end, you can drop the #ifdef around pte_next_pfn here. >