Message ID | 20240202080756.1453939-4-ryan.roberts@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-49415-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp278359dyc; Fri, 2 Feb 2024 00:09:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHq73RsJG3M41kmLTvOWX2fqOjhxeFF/msqrQ8YtZXqSY8kSnX1tCv2sD6BaNJ+KAsIHZtf X-Received: by 2002:a17:906:1c15:b0:a35:7132:26d5 with SMTP id k21-20020a1709061c1500b00a35713226d5mr4932932ejg.63.1706861384637; Fri, 02 Feb 2024 00:09:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706861384; cv=pass; d=google.com; s=arc-20160816; b=J/RupANBTUXfPQUgOTr5cRnmZLKWLbNxLb+qeYHRWrA3qv+qhWQ4MARZNXwDuSVh+S xPHz5RNoeJtaIacg7lWaBUgr6W6EndKpCMjwc1sqWRuR9XYrX/2y6Q454uhg5/UkNH6L QAoYVZFxQyESwg1Edn29qDp3s9YwgQswkokMcKRlvAh2Y1F6F/wGXKonEt8w6eVRFlEm 4qa/XZC3lSfvWPaTc3MA5UaRcXqRPBh6ArZu/AbgmlI98MyHgJoFbfHBXlbUsO5UDMQ/ YKejnkFvtGON5yFCVUdardtMIcdVoH4zM0654J+m/gz2T1gmsBmL5qJDRpAd6aQdiOSl ojeg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=MiB2yK22g/POYHUygPxWvSb+30lGFDNWNkV8pOKxEt0=; fh=ST8yVJUKnvLlYqXlTKbEAx0V3QHrCt22tS85TPv5VSI=; b=CPp7NOpsamEsw42E4Paswr+971sqCjWM9c5bLvjkmiHPTFZiW8HH45eXydFVdvIgmt u1kDIBCkDvS+IOb7jP7ix0VVkVyjDrlLjIH4gsofB1ErWy9LXVUH1sY0QoIPUo0i+1Y6 /G9qcdmT4QU49w31zwv7dLvYgAa8lLORXGZ9eta9Owd/yMxar/yZJFjeKKNOxADPEGIv TBwhCZz/3tGYXnJ73I0nLSjIpPTTdkfSY/6M5fnLmK4X99QIpR7DZ7oZyR/sU1N2PcUX YvzGajNq0GHuCyyCF6nvaRlePXJuNLmJBx0UyGcN7JobLI+3g0dRWPafJKs0bhONzkFy P7QA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-49415-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49415-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=1; AJvYcCXXkk7FXV+u25iyeICOLypGLQGXjXqVwyNmsrQqlSeXN4A9R87Z/NpgfYU8H2KNyKPy6JrJboQHppZvulovBIIRbJtRoQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k15-20020a170906a38f00b00a36fb0c6424si475772ejz.61.2024.02.02.00.09.44 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:09:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49415-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-49415-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49415-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 410151F2A724 for <ouuuleilei@gmail.com>; Fri, 2 Feb 2024 08:09:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4D5A199BA; Fri, 2 Feb 2024 08:08:31 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6361218E1A for <linux-kernel@vger.kernel.org>; Fri, 2 Feb 2024 08:08:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706861310; cv=none; b=c881Vo5p4UE9Iq9fK7pUNnw8KNTcH0bDe9Gj4ftMmrXnZl2tu7byklPwDROvPiSGGwKn2kW+bnT3WTZz3CuGZ8Oxx2gk/1q9MMCdKLpeKL3mdG5xJEQWZPTtSnFMxG5xclvrPC+wfXFy+ZowC7g+Ojf5Mb0Xp5UvjU19awlBzvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706861310; c=relaxed/simple; bh=ilkctyHCFTKph7SguchDk3Oqzwpxdv9pwaYrbYycKgQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=khWin5suZO0qkx6sPjk7iohPp7VxrDncpmKVhK1kOxJgFlB0jy2kLoS16BkZulkAbJlBcPT91N9MLKHC2jWeqKVPY6/gxQewynHclxgUJ0THYiKVE02Y/qtckUuOVORWbkJTvCdyKgsLyi6X/0eORCULwphVzmeF5hVeIsBw4VI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 2865B169E; Fri, 2 Feb 2024 00:09:10 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3C7A53F5A1; Fri, 2 Feb 2024 00:08:24 -0800 (PST) From: Ryan Roberts <ryan.roberts@arm.com> To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>, Marc Zyngier <maz@kernel.org>, James Morse <james.morse@arm.com>, Andrey Ryabinin <ryabinin.a.a@gmail.com>, Andrew Morton <akpm@linux-foundation.org>, Matthew Wilcox <willy@infradead.org>, Mark Rutland <mark.rutland@arm.com>, David Hildenbrand <david@redhat.com>, Kefeng Wang <wangkefeng.wang@huawei.com>, John Hubbard <jhubbard@nvidia.com>, Zi Yan <ziy@nvidia.com>, Barry Song <21cnbao@gmail.com>, Alistair Popple <apopple@nvidia.com>, Yang Shi <shy828301@gmail.com>, Nicholas Piggin <npiggin@gmail.com>, Christophe Leroy <christophe.leroy@csgroup.eu>, "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>, "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Dave Hansen <dave.hansen@linux.intel.com>, "H. Peter Anvin" <hpa@zytor.com> Cc: Ryan Roberts <ryan.roberts@arm.com>, linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 03/25] mm: Make pte_next_pfn() a wrapper around pte_advance_pfn() Date: Fri, 2 Feb 2024 08:07:34 +0000 Message-Id: <20240202080756.1453939-4-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240202080756.1453939-1-ryan.roberts@arm.com> References: <20240202080756.1453939-1-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789773883196876574 X-GMAIL-MSGID: 1789773883196876574 |
Series |
Transparent Contiguous PTEs for User Mappings
|
|
Commit Message
Ryan Roberts
Feb. 2, 2024, 8:07 a.m. UTC
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 <ryan.roberts@arm.com>
---
include/linux/pgtable.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Comments
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 <ryan.roberts@arm.com> > --- > 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? 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.
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 <ryan.roberts@arm.com> >> --- >> 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. >
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 <ryan.roberts@arm.com> >>> --- >>> 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.
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 <ryan.roberts@arm.com> >>>> --- >>>> 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.
On 12.02.24 22:34, Ryan Roberts wrote: > 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 <ryan.roberts@arm.com> >>>>> --- >>>>> 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. Oh, I say stupid things all the time. Please push back if you disagree. :) [shrinking a patch set if possible and reasonable is often a good idea]
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