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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3DC4C4829E for ; Mon, 12 Feb 2024 21:35:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDCF76B006E; Mon, 12 Feb 2024 16:35:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B8D266B0071; Mon, 12 Feb 2024 16:35:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A54DE6B0072; Mon, 12 Feb 2024 16:35:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 916666B006E for ; Mon, 12 Feb 2024 16:35:03 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2E82E80AF1 for ; Mon, 12 Feb 2024 21:35:03 +0000 (UTC) X-FDA: 81784457286.19.8D22DAF Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf25.hostedemail.com (Postfix) with ESMTP id D30D1A0018 for ; Mon, 12 Feb 2024 21:34:59 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707773700; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ezCFWDPU/964l4xHy+gnRpKaMt1AZzGT+KUxftVSGfQ=; b=YGkkH8imzNazZWYAIj6bcjLIUkIfHm1n6xPl7zfb3PCKtjjQ8QHq2LPoJv0p/zeuvMPFWA 7T5e03QZKzxZMMb4Gx3JJkDl3yble1jY+wfwpH0HgJ6wq3Y5s3ZJ4g2BghuqHkbhFjuKIa P+n+hpg5NfsfqPrlANALh2X2qUMcB3U= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; spf=pass (imf25.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707773700; a=rsa-sha256; cv=none; b=PHN4lbbGKKdrhI/lQ3JCVsQfRPBu4uF/i6pZ8R22GS8Yr45cWWh6BIuU5IQRdjGdzrYitD zlb7EZH6UVSjxxn86iszWONg4SMqyB4yMcqk07A48fiCRp75cqpPZ+17pA9F5WY8RLDwts a8omq+zLNL0CiCZccoUWq3vcqICRsdc= 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 EE8BEDA7; Mon, 12 Feb 2024 13:35:39 -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 CF5003F766; Mon, 12 Feb 2024 13:34:54 -0800 (PST) Message-ID: <3bc05163-2671-4239-ae5a-b9207fdca459@arm.com> Date: Mon, 12 Feb 2024 21:34:53 +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" Cc: linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240202080756.1453939-1-ryan.roberts@arm.com> <20240202080756.1453939-4-ryan.roberts@arm.com> <828d2573-b5fe-43b3-b955-944c05bcdb60@redhat.com> From: Ryan Roberts In-Reply-To: <828d2573-b5fe-43b3-b955-944c05bcdb60@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D30D1A0018 X-Rspam-User: X-Stat-Signature: zm6wz77qppz4mk7cjq3qdqnzethdc9a6 X-Rspamd-Server: rspam01 X-HE-Tag: 1707773699-186256 X-HE-Meta: U2FsdGVkX1/1+fAWNRHzTZoni7m4bVuExYTCmHS4+wOKQzYaADYkj2ahR5rs9MgmvZFqb3mitwXEeU6mOAI/w9rMdMv31NIi9mm5FNQL7vHN2BAcLqKnEoeW2GdFssHuTw+avIseiiuWTHr7tbmGbuRr7Z42bGUfrKat25qL58U+BL9s7f8V93juxZAEviwQ6YjZFIB2QHZpBkcYqY9ZBDTbbEuVHkeYau7MBaRBBDpadXDxorMgvLojJ6TyArhwEXPTUQxIO+ciQgGW7kE7A10UEkLshyQg+Kq0f5hCufeodHCbp2iMKikZeXIOvMd/0TiGZgYj6/8DDJWsMTm/XoawMurNolqNJKosIoxBfbVgzVQ9horZSLCBJJPuDyS9FnvCKMEdEqHx4gIvcutBrXoEwV6vddwpQmBfpeOmBBu0BzpFBVSbhPWKpMbjXOD51oNSayG+cx1NZRkn90Nis1I8qtql6sPWQYbDfLJM/u+RmNwmM8Rc9/HgyiP3Ls3a+eYUPTGTOKniBvWqCzmX8FNLJydjHXnsDRw+KmH1Igci6T2cH7cKXuhoSZHm8JO7E2w3JXqzVjPuYN6soKP21KYWUepESGBjwHNcode9eSfxETXTX3pVFiibIKVFdTF5vXj0dUv6PxVa5eydlfHVhnIEAVFq5H5OJ32qzAIl/y4G6yk5M9m+6fQEvreVJJo61I1g3dGsdQ14S6ASYCsadVvjYbKy83l6atMX0DC1Y4wLu2kimYYu9fp04f6Xr0QnmuF7lIVwF0wfiNaTjDWn9su2u6Vo1gtap+3tkPOAeKbjmmTVQigdxYkSjT6a4sljPctHyk++G4fn5UaogtNQDDm/YLIIXYlPxXLlrg+WDMKMY1b4hpORgx9tTpbdI6J1cJ/3ZulWOdP6ooyP92vtYsx9ERwMpyt7l/G8UqJwD/VWSoAE7HYDniw8pBYp7cY8n2knnfO+5rfgfD/+LVZ +bB6oWGP HNjsjAjaRFrJ+/QLq3PmBpLNmjZd+tI7H/F/KZQMfHZpXXVfn1yRRFKM4OdDjM1CyS0w7C+BDwllYurNaoPBjxz+0yBhisc/KixJ9W4twLx+1whXx2KQEA/kudnpqE7+w3YV1tb3WroSn/w0nLSr6vIek4MUybSjwSAmzzD0rVhB0Vm8j+sKxbJFFJUkwMHGcHmj7insarvYsF8iPwmuncstgA0yu7fAh67MkofX+zc9PWjrZFnnnFtYIJVBx/jyujtEuxZWaGo4L8qonWM9WVy6L0DsM6L+0FBiAxvPZYEtLn1Hn3ulNqX79dfQ3fwNgoRg8crHedNLDSzI= 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: On 12/02/2024 14:29, David Hildenbrand wrote: > On 12.02.24 15:10, Ryan Roberts wrote: >> 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. > > Well, not really functions, just a macro. Like we have set_pte_at() translating > to set_ptes(). > > Arguably, we have more callers of set_pte_at(). > > "Easier to understand", I don't know. :) > >> >> 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. > > Well, it makes you patch set shorter and there is less code churn. > > So personally, I'd just leave pte_next_pfn() in there. But whatever you prefer, > not the end of the world. I thought about this a bit more and remembered that I'm the apprentice so I've changed it as you suggested.