* [PATCH 1/3] s390/mm: Drop all pxdp_get()
2026-09-23 4:32 [PATCH 0/3] arch/mm: Drop similar platform overrides for pxdp_get() Anshuman Khandual
@ 2026-09-23 4:32 ` Anshuman Khandual
2026-09-23 4:42 ` sashiko-bot
2026-09-23 9:16 ` Heiko Carstens
2026-09-23 4:32 ` [PATCH 2/3] loongarch/mm: " Anshuman Khandual
2026-09-23 4:32 ` [PATCH 3/3] parisc/mm: " Anshuman Khandual
2 siblings, 2 replies; 12+ messages in thread
From: Anshuman Khandual @ 2026-09-23 4:32 UTC (permalink / raw)
To: linux-mm
Cc: Anshuman Khandual, David Hildenbrand, Andrew Morton,
Alexander Gordeev, Gerald Schaefer, Huacai Chen, WANG Xuerui,
Helge Deller, loongarch, linux-s390, linux-parisc, linux-kernel
Current platform specific pxdp_get() helpers are exact same as the default
ones defined in the generic MM header (include/linux/pgtable.h) thus making
them redundant. Just add required forward declarations.
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: linux-s390@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/s390/include/asm/pgtable.h | 35 +++++----------------------------
1 file changed, 5 insertions(+), 30 deletions(-)
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index e882663a58e77..0a0b0ec42b624 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -25,6 +25,11 @@
#include <asm/page.h>
#include <asm/uv.h>
+static inline pte_t ptep_get(const pte_t *ptep);
+static inline pud_t pudp_get(const pud_t *pudp);
+static inline p4d_t p4dp_get(const p4d_t *p4dp);
+static inline pgd_t pgdp_get(const pgd_t *pgdp);
+
extern pgd_t swapper_pg_dir[];
extern pgd_t invalid_pg_dir[];
extern void paging_init(void);
@@ -985,36 +990,6 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
WRITE_ONCE(*ptep, pte);
}
-#define ptep_get ptep_get
-static inline pte_t ptep_get(pte_t *ptep)
-{
- return READ_ONCE(*ptep);
-}
-
-#define pmdp_get pmdp_get
-static inline pmd_t pmdp_get(pmd_t *pmdp)
-{
- return READ_ONCE(*pmdp);
-}
-
-#define pudp_get pudp_get
-static inline pud_t pudp_get(pud_t *pudp)
-{
- return READ_ONCE(*pudp);
-}
-
-#define p4dp_get p4dp_get
-static inline p4d_t p4dp_get(p4d_t *p4dp)
-{
- return READ_ONCE(*p4dp);
-}
-
-#define pgdp_get pgdp_get
-static inline pgd_t pgdp_get(pgd_t *pgdp)
-{
- return READ_ONCE(*pgdp);
-}
-
static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
{
set_pte(ptep, __pte(_PAGE_INVALID));
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 1/3] s390/mm: Drop all pxdp_get()
2026-09-23 4:32 ` [PATCH 1/3] s390/mm: Drop all pxdp_get() Anshuman Khandual
@ 2026-09-23 4:42 ` sashiko-bot
2026-09-23 9:16 ` Heiko Carstens
1 sibling, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-09-23 4:42 UTC (permalink / raw)
To: Anshuman Khandual
Cc: linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Christian Borntraeger
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] mm: s390 build failure due to conflicting types for pxdp_get() helpers
--
commit f8684b75ea3db8facc582e1cba2e98f8430ce2eb
Author: Anshuman Khandual <anshuman.khandual@arm.com>
s390/mm: Drop all pxdp_get()
This commit removes the s390 platform-specific pxdp_get() helpers, relying
instead on the generic definitions in the core MM headers. It also adds
forward declarations for these generic helpers to satisfy local dependencies.
> diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
> index e882663a58e77..0a0b0ec42b624 100644
> --- a/arch/s390/include/asm/pgtable.h
> +++ b/arch/s390/include/asm/pgtable.h
> @@ -25,6 +25,11 @@
> #include <asm/page.h>
> #include <asm/uv.h>
>
> +static inline pte_t ptep_get(const pte_t *ptep);
> +static inline pud_t pudp_get(const pud_t *pudp);
> +static inline p4d_t p4dp_get(const p4d_t *p4dp);
> +static inline pgd_t pgdp_get(const pgd_t *pgdp);
[Severity: Low]
Does this cause a build failure on s390 due to conflicting types?
These forward declarations define the parameters as const pointers, but the
generic fallback definitions specify a non-const pointer. For example, in
include/linux/pgtable.h:
static inline pte_t ptep_get(pte_t *ptep)
{
return READ_ONCE(*ptep);
}
This mismatch between const pte_t * and pte_t * appears to result in a fatal
compile-time error during the build.
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260923043226.331880-1-anshuman.khandual@arm.com?part=1
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 1/3] s390/mm: Drop all pxdp_get()
2026-09-23 4:32 ` [PATCH 1/3] s390/mm: Drop all pxdp_get() Anshuman Khandual
2026-09-23 4:42 ` sashiko-bot
@ 2026-09-23 9:16 ` Heiko Carstens
2026-09-23 12:12 ` Anshuman Khandual
1 sibling, 1 reply; 12+ messages in thread
From: Heiko Carstens @ 2026-09-23 9:16 UTC (permalink / raw)
To: Anshuman Khandual
Cc: linux-mm, David Hildenbrand, Andrew Morton, Alexander Gordeev,
Gerald Schaefer, Huacai Chen, WANG Xuerui, Helge Deller,
loongarch, linux-s390, linux-parisc, linux-kernel
On Wed, Sep 23, 2026 at 10:02:20AM +0530, Anshuman Khandual wrote:
> Current platform specific pxdp_get() helpers are exact same as the default
> ones defined in the generic MM header (include/linux/pgtable.h) thus making
> them redundant. Just add required forward declarations.
>
> Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
> Cc: linux-s390@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> arch/s390/include/asm/pgtable.h | 35 +++++----------------------------
> 1 file changed, 5 insertions(+), 30 deletions(-)
>
> diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
> index e882663a58e77..0a0b0ec42b624 100644
> --- a/arch/s390/include/asm/pgtable.h
> +++ b/arch/s390/include/asm/pgtable.h
> @@ -25,6 +25,11 @@
> #include <asm/page.h>
> #include <asm/uv.h>
>
> +static inline pte_t ptep_get(const pte_t *ptep);
> +static inline pud_t pudp_get(const pud_t *pudp);
> +static inline p4d_t p4dp_get(const p4d_t *p4dp);
> +static inline pgd_t pgdp_get(const pgd_t *pgdp);
> +
> extern pgd_t swapper_pg_dir[];
> extern pgd_t invalid_pg_dir[];
> extern void paging_init(void);
> @@ -985,36 +990,6 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
> WRITE_ONCE(*ptep, pte);
> }
>
> -#define ptep_get ptep_get
> -static inline pte_t ptep_get(pte_t *ptep)
> -{
> - return READ_ONCE(*ptep);
> -}
As reported by Sashiko, this results in a compile error due to conflicting
types; but I don't see too much value with this patch if a forward declaration
of the common code implementation needs to be added instead. Looks like s390
would be the only architecture which would have that.
Besides that the s390 implementation of ptep_get() will be filled with
more content "soon", when Alexander's lazy mmu work will be merged.
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 1/3] s390/mm: Drop all pxdp_get()
2026-09-23 9:16 ` Heiko Carstens
@ 2026-09-23 12:12 ` Anshuman Khandual
2026-09-23 14:32 ` Heiko Carstens
0 siblings, 1 reply; 12+ messages in thread
From: Anshuman Khandual @ 2026-09-23 12:12 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-mm, David Hildenbrand, Andrew Morton, Alexander Gordeev,
Gerald Schaefer, Huacai Chen, WANG Xuerui, Helge Deller,
loongarch, linux-s390, linux-parisc, linux-kernel
On Wed, Sep 23, 2026 at 11:16:29AM +0200, Heiko Carstens wrote:
> On Wed, Sep 23, 2026 at 10:02:20AM +0530, Anshuman Khandual wrote:
> > Current platform specific pxdp_get() helpers are exact same as the default
> > ones defined in the generic MM header (include/linux/pgtable.h) thus making
> > them redundant. Just add required forward declarations.
> >
> > Cc: Alexander Gordeev <agordeev@linux.ibm.com>
> > Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
> > Cc: linux-s390@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-mm@kvack.org
> > Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> > ---
> > arch/s390/include/asm/pgtable.h | 35 +++++----------------------------
> > 1 file changed, 5 insertions(+), 30 deletions(-)
> >
> > diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
> > index e882663a58e77..0a0b0ec42b624 100644
> > --- a/arch/s390/include/asm/pgtable.h
> > +++ b/arch/s390/include/asm/pgtable.h
> > @@ -25,6 +25,11 @@
> > #include <asm/page.h>
> > #include <asm/uv.h>
> >
> > +static inline pte_t ptep_get(const pte_t *ptep);
> > +static inline pud_t pudp_get(const pud_t *pudp);
> > +static inline p4d_t p4dp_get(const p4d_t *p4dp);
> > +static inline pgd_t pgdp_get(const pgd_t *pgdp);
> > +
> > extern pgd_t swapper_pg_dir[];
> > extern pgd_t invalid_pg_dir[];
> > extern void paging_init(void);
> > @@ -985,36 +990,6 @@ static inline void set_pte(pte_t *ptep, pte_t pte)
> > WRITE_ONCE(*ptep, pte);
> > }
> >
> > -#define ptep_get ptep_get
> > -static inline pte_t ptep_get(pte_t *ptep)
> > -{
> > - return READ_ONCE(*ptep);
> > -}
>
> As reported by Sashiko, this results in a compile error due to conflicting
> types; but I don't see too much value with this patch if a forward declaration
> of the common code implementation needs to be added instead. Looks like s390
> would be the only architecture which would have that.
We could move pxdp_get() caller functions from this header inside C files
like other platform changes proposed here. Would that be better instead ?
>
> Besides that the s390 implementation of ptep_get() will be filled with
> more content "soon", when Alexander's lazy mmu work will be merged.
Hmm, okay. I don't have strong opinion either way.
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 1/3] s390/mm: Drop all pxdp_get()
2026-09-23 12:12 ` Anshuman Khandual
@ 2026-09-23 14:32 ` Heiko Carstens
2026-09-24 2:37 ` Anshuman Khandual
0 siblings, 1 reply; 12+ messages in thread
From: Heiko Carstens @ 2026-09-23 14:32 UTC (permalink / raw)
To: Anshuman Khandual
Cc: linux-mm, David Hildenbrand, Andrew Morton, Alexander Gordeev,
Gerald Schaefer, Huacai Chen, WANG Xuerui, Helge Deller,
loongarch, linux-s390, linux-parisc, linux-kernel
On Wed, Sep 23, 2026 at 05:42:00PM +0530, Anshuman Khandual wrote:
> On Wed, Sep 23, 2026 at 11:16:29AM +0200, Heiko Carstens wrote:
> > On Wed, Sep 23, 2026 at 10:02:20AM +0530, Anshuman Khandual wrote:
> > > +static inline pte_t ptep_get(const pte_t *ptep);
> > > +static inline pud_t pudp_get(const pud_t *pudp);
> > > +static inline p4d_t p4dp_get(const p4d_t *p4dp);
> > > +static inline pgd_t pgdp_get(const pgd_t *pgdp);
...
> > > -#define ptep_get ptep_get
> > > -static inline pte_t ptep_get(pte_t *ptep)
> > > -{
> > > - return READ_ONCE(*ptep);
> > > -}
> >
> > As reported by Sashiko, this results in a compile error due to conflicting
> > types; but I don't see too much value with this patch if a forward declaration
> > of the common code implementation needs to be added instead. Looks like s390
> > would be the only architecture which would have that.
>
> We could move pxdp_get() caller functions from this header inside C files
> like other platform changes proposed here. Would that be better instead ?
That would make pud_clear() & friends real functions calls instead of being
inlined. Function calls are more expensive, so I would like to avoid that.
I would prefer to drop this patch.
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 1/3] s390/mm: Drop all pxdp_get()
2026-09-23 14:32 ` Heiko Carstens
@ 2026-09-24 2:37 ` Anshuman Khandual
0 siblings, 0 replies; 12+ messages in thread
From: Anshuman Khandual @ 2026-09-24 2:37 UTC (permalink / raw)
To: Heiko Carstens
Cc: linux-mm, David Hildenbrand, Andrew Morton, Alexander Gordeev,
Gerald Schaefer, Huacai Chen, WANG Xuerui, Helge Deller,
loongarch, linux-s390, linux-parisc, linux-kernel
On Wed, Sep 23, 2026 at 04:32:47PM +0200, Heiko Carstens wrote:
> On Wed, Sep 23, 2026 at 05:42:00PM +0530, Anshuman Khandual wrote:
> > On Wed, Sep 23, 2026 at 11:16:29AM +0200, Heiko Carstens wrote:
> > > On Wed, Sep 23, 2026 at 10:02:20AM +0530, Anshuman Khandual wrote:
> > > > +static inline pte_t ptep_get(const pte_t *ptep);
> > > > +static inline pud_t pudp_get(const pud_t *pudp);
> > > > +static inline p4d_t p4dp_get(const p4d_t *p4dp);
> > > > +static inline pgd_t pgdp_get(const pgd_t *pgdp);
> ...
> > > > -#define ptep_get ptep_get
> > > > -static inline pte_t ptep_get(pte_t *ptep)
> > > > -{
> > > > - return READ_ONCE(*ptep);
> > > > -}
> > >
> > > As reported by Sashiko, this results in a compile error due to conflicting
> > > types; but I don't see too much value with this patch if a forward declaration
> > > of the common code implementation needs to be added instead. Looks like s390
> > > would be the only architecture which would have that.
> >
> > We could move pxdp_get() caller functions from this header inside C files
> > like other platform changes proposed here. Would that be better instead ?
>
> That would make pud_clear() & friends real functions calls instead of being
> inlined. Function calls are more expensive, so I would like to avoid that.
>
> I would prefer to drop this patch.
Alright, thanks for your review.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/3] loongarch/mm: Drop all pxdp_get()
2026-09-23 4:32 [PATCH 0/3] arch/mm: Drop similar platform overrides for pxdp_get() Anshuman Khandual
2026-09-23 4:32 ` [PATCH 1/3] s390/mm: Drop all pxdp_get() Anshuman Khandual
@ 2026-09-23 4:32 ` Anshuman Khandual
2026-09-23 4:41 ` sashiko-bot
2026-09-23 4:32 ` [PATCH 3/3] parisc/mm: " Anshuman Khandual
2 siblings, 1 reply; 12+ messages in thread
From: Anshuman Khandual @ 2026-09-23 4:32 UTC (permalink / raw)
To: linux-mm
Cc: Anshuman Khandual, David Hildenbrand, Andrew Morton,
Alexander Gordeev, Gerald Schaefer, Huacai Chen, WANG Xuerui,
Helge Deller, loongarch, linux-s390, linux-parisc, linux-kernel
Current platform specific pxdp_get() helpers are exact same as the default
ones defined in the generic MM header (include/linux/pgtable.h) thus making
them redundant. Move functions that are now depending on generic helpers to
avoid build failure.
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: loongarch@lists.linux.dev
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/loongarch/include/asm/pgtable.h | 20 ++------------------
arch/loongarch/mm/init.c | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
index a05f6a4928dc6..b1060b86d5353 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -132,9 +132,6 @@ struct vm_area_struct;
#define DIRECT_MAP_PHYSMEM_END min((1ULL << (cpu_pabits + 1)) - 1, (1ULL << MAX_PHYSMEM_BITS) - 1)
#endif
-#define ptep_get(ptep) READ_ONCE(*(ptep))
-#define pmdp_get(pmdp) READ_ONCE(*(pmdp))
-
#define pte_ERROR(e) \
pr_err("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e))
#ifndef __PAGETABLE_PMD_FOLDED
@@ -378,12 +375,7 @@ static inline void set_pte(pte_t *ptep, pte_t pteval)
#endif
}
-static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
-{
- pte_t pte = ptep_get(ptep);
- pte_val(pte) &= _PAGE_GLOBAL;
- set_pte(ptep, pte);
-}
+void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
#define PGD_T_LOG2 (__builtin_ffs(sizeof(pgd_t)) - 1)
#define PMD_T_LOG2 (__builtin_ffs(sizeof(pmd_t)) - 1)
@@ -618,16 +610,8 @@ static inline pmd_t pmd_mkinvalid(pmd_t pmd)
* different prototype.
*/
#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
-static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
- unsigned long address, pmd_t *pmdp)
-{
- pmd_t old = pmdp_get(pmdp);
-
- pmd_clear(pmdp);
-
- return old;
-}
+pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, unsigned long address, pmd_t *pmdp);
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
#ifdef CONFIG_ARCH_HAS_PTE_PROTNONE
diff --git a/arch/loongarch/mm/init.c b/arch/loongarch/mm/init.c
index 4b46c5d30708d..5751b3bcca994 100644
--- a/arch/loongarch/mm/init.c
+++ b/arch/loongarch/mm/init.c
@@ -266,3 +266,22 @@ struct execmem_info __init *execmem_arch_setup(void)
return &execmem_info;
}
#endif /* CONFIG_EXECMEM && MODULES_VADDR */
+
+void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+ pte_t pte = ptep_get(ptep);
+
+ pte_val(pte) &= _PAGE_GLOBAL;
+ set_pte(ptep, pte);
+}
+
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, unsigned long address, pmd_t *pmdp)
+{
+ pmd_t old = pmdp_get(pmdp);
+
+ pmd_clear(pmdp);
+
+ return old;
+}
+#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 2/3] loongarch/mm: Drop all pxdp_get()
2026-09-23 4:32 ` [PATCH 2/3] loongarch/mm: " Anshuman Khandual
@ 2026-09-23 4:41 ` sashiko-bot
0 siblings, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-09-23 4:41 UTC (permalink / raw)
To: Anshuman Khandual
Cc: Alexander Gordeev, Heiko Carstens, Christian Borntraeger,
linux-s390, Vasily Gorbik
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mm: performance regression from de-inlining pte_clear()
--
commit 5d80651056844549679369970919b58e26bc34bf
Author: Anshuman Khandual <anshuman.khandual@arm.com>
loongarch/mm: Drop all pxdp_get()
This patch removes redundant loongarch-specific pxdp_get() helpers, relying
on the generic ones from include/linux/pgtable.h. To prevent build failures,
it moves some dependent functions to out-of-line implementations.
> diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
> index a05f6a4928dc6..b1060b86d5353 100644
> --- a/arch/loongarch/include/asm/pgtable.h
> +++ b/arch/loongarch/include/asm/pgtable.h
[ ... ]
> @@ -378,12 +375,7 @@ static inline void set_pte(pte_t *ptep, pte_t pteval)
> #endif
> }
>
> -static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
> -{
> - pte_t pte = ptep_get(ptep);
> - pte_val(pte) &= _PAGE_GLOBAL;
> - set_pte(ptep, pte);
> -}
> +void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
[Severity: High]
Does removing 'static inline' and moving pte_clear() out-of-line introduce a
performance regression?
pte_clear() is a core memory management primitive executed iteratively in
extremely hot paths. For instance, zap_pte_range() processes up to 512 PTEs
per PMD during munmap or madvise. Replacing inline bitwise operations with
function calls during large VMA teardown introduces a significant overhead
for any unprivileged process allocating and freeing memory.
Could this be avoided by expanding ptep_get(ptep) to its equivalent
READ_ONCE(*ptep) inside the inline definition instead of moving the function
out-of-line?
[ ... ]
> @@ -618,16 +610,8 @@ static inline pmd_t pmd_mkinvalid(pmd_t pmd)
> * different prototype.
> */
> #define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
> -static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
> - unsigned long address, pmd_t *pmdp)
> -{
> - pmd_t old = pmdp_get(pmdp);
> -
> - pmd_clear(pmdp);
> -
> - return old;
> -}
>
> +pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, unsigned long address, pmd_t *pmdp);
[Severity: High]
Does moving pmdp_huge_get_and_clear() out-of-line similarly negatively impact
THP teardown performance?
Like pte_clear(), this function operates on hot paths, and substituting an
inline definition with a function call introduces overhead. Could this also
be kept inline by expanding pmdp_get(pmdp) to READ_ONCE(*pmdp)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260923043226.331880-1-anshuman.khandual@arm.com?part=2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] parisc/mm: Drop all pxdp_get()
2026-09-23 4:32 [PATCH 0/3] arch/mm: Drop similar platform overrides for pxdp_get() Anshuman Khandual
2026-09-23 4:32 ` [PATCH 1/3] s390/mm: Drop all pxdp_get() Anshuman Khandual
2026-09-23 4:32 ` [PATCH 2/3] loongarch/mm: " Anshuman Khandual
@ 2026-09-23 4:32 ` Anshuman Khandual
2026-09-23 4:42 ` sashiko-bot
2 siblings, 1 reply; 12+ messages in thread
From: Anshuman Khandual @ 2026-09-23 4:32 UTC (permalink / raw)
To: linux-mm
Cc: Anshuman Khandual, David Hildenbrand, Andrew Morton,
Alexander Gordeev, Gerald Schaefer, Huacai Chen, WANG Xuerui,
Helge Deller, loongarch, linux-s390, linux-parisc, linux-kernel
Current platform specific pxdp_get() helpers are exact same as the default
ones defined in the generic MM header (include/linux/pgtable.h) thus making
them redundant. Move functions that are now depending on generic helpers to
avoid build failure.
Cc: “James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: linux-parisc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/parisc/include/asm/pgtable.h | 20 +-------------------
arch/parisc/mm/init.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index 467b8547ac8bf..975aa283b4c13 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -432,25 +432,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
return pte;
}
-static inline pte_t ptep_get(pte_t *ptep)
-{
- return READ_ONCE(*ptep);
-}
-#define ptep_get ptep_get
-
-static inline bool ptep_test_and_clear_young(struct vm_area_struct *vma,
- unsigned long addr, pte_t *ptep)
-{
- pte_t pte;
-
- pte = ptep_get(ptep);
- if (!pte_young(pte)) {
- return false;
- }
- set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
- return true;
-}
-
+bool ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep);
bool ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep);
pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep);
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index be3380c9bcdae..3da7d8def9435 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -992,3 +992,16 @@ struct execmem_info __init *execmem_arch_setup(void)
return &execmem_info;
}
#endif /* CONFIG_EXECMEM */
+
+bool ptep_test_and_clear_young(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep)
+{
+ pte_t pte;
+
+ pte = ptep_get(ptep);
+ if (!pte_young(pte))
+ return false;
+
+ set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
+ return true;
+}
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 3/3] parisc/mm: Drop all pxdp_get()
2026-09-23 4:32 ` [PATCH 3/3] parisc/mm: " Anshuman Khandual
@ 2026-09-23 4:42 ` sashiko-bot
0 siblings, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-09-23 4:42 UTC (permalink / raw)
To: Anshuman Khandual
Cc: Heiko Carstens, linux-s390, Alexander Gordeev,
Christian Borntraeger, Vasily Gorbik
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] mm: unnecessary out-of-line conversion of ptep_test_and_clear_young()
--
commit 6892dae5d3895dcd59fc83328a1aca2f33ba942b
Author: Anshuman Khandual <anshuman.khandual@arm.com>
parisc/mm: Drop all pxdp_get()
This commit drops the redundant platform-specific pxdp_get() helpers in
favor of the generic MM header definitions. It also moves dependent functions
like ptep_test_and_clear_young() out-of-line to avoid build failures.
> diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
> index be3380c9bcdae..3da7d8def9435 100644
> --- a/arch/parisc/mm/init.c
> +++ b/arch/parisc/mm/init.c
> @@ -992,3 +992,16 @@ struct execmem_info __init *execmem_arch_setup(void)
> return &execmem_info;
> }
> #endif /* CONFIG_EXECMEM */
> +
> +bool ptep_test_and_clear_young(struct vm_area_struct *vma,
> + unsigned long addr, pte_t *ptep)
> +{
> + pte_t pte;
> +
> + pte = ptep_get(ptep);
> + if (!pte_young(pte))
> + return false;
> +
> + set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
> + return true;
> +}
[Severity: Medium]
Is there a reason this function was moved out-of-line instead of dropping
the custom implementation entirely?
This implementation perfectly matches the generic inline default provided in
include/linux/pgtable.h. Since this path is called heavily during memory
pressure and page reclaim, such as from page_referenced_one(), moving it
out-of-line introduces function call overhead for every PTE scanned.
Could we instead remove the __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG definition
in arch/parisc/include/asm/pgtable.h? This would allow the compiler to use
the generic inline fallback and avoid the performance regression.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260923043226.331880-1-anshuman.khandual@arm.com?part=3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] parisc/mm: Drop all pxdp_get()
2026-09-19 10:13 [PATCH 0/3] arch/mm: Drop similar platform overrides for pxdp_get() Anshuman Khandual
@ 2026-09-19 10:13 ` Anshuman Khandual
0 siblings, 0 replies; 12+ messages in thread
From: Anshuman Khandual @ 2026-09-19 10:13 UTC (permalink / raw)
To: linux-mm
Cc: Anshuman Khandual, David Hildenbrand, Andrew Morton,
Alexander Gordeev, Gerald Schaefer, Huacai Chen, WANG Xuerui,
Helge Deller, loongarch, linux-s390, linux-parisc, linux-kernel
Current platform specific pxdp_get() helpers are exact same as the default
ones defined in the generic MM header (include/linux/pgtable.h) thus making
them redundant. Move functions that are now depending on generic helpers to
avoid build failure.
Cc: “James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: linux-parisc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
arch/parisc/include/asm/pgtable.h | 20 +-------------------
arch/parisc/mm/init.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index 467b8547ac8bf..975aa283b4c13 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -432,25 +432,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
return pte;
}
-static inline pte_t ptep_get(pte_t *ptep)
-{
- return READ_ONCE(*ptep);
-}
-#define ptep_get ptep_get
-
-static inline bool ptep_test_and_clear_young(struct vm_area_struct *vma,
- unsigned long addr, pte_t *ptep)
-{
- pte_t pte;
-
- pte = ptep_get(ptep);
- if (!pte_young(pte)) {
- return false;
- }
- set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
- return true;
-}
-
+bool ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep);
bool ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep);
pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep);
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index be3380c9bcdae..3da7d8def9435 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -992,3 +992,16 @@ struct execmem_info __init *execmem_arch_setup(void)
return &execmem_info;
}
#endif /* CONFIG_EXECMEM */
+
+bool ptep_test_and_clear_young(struct vm_area_struct *vma,
+ unsigned long addr, pte_t *ptep)
+{
+ pte_t pte;
+
+ pte = ptep_get(ptep);
+ if (!pte_young(pte))
+ return false;
+
+ set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
+ return true;
+}
--
2.43.0
^ permalink raw reply related [flat|nested] 12+ messages in thread