Skip to contentSkip to conversation

perf/events: Replace READ_ONCE() with standard pgtable accessors

PATCH Applied Anshuman Khandual 6 participants 13 messages Feb 27 – Apr 9

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/events: Replace READ_ONCE() with standard pgtable accessors

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

---
This patch applies both on v7.0-rc1 and mm-unstable.

Part of the D128 series but independent. Hence could be considered on its own.

https://lore.kernel.org/all/[email protected]/

Collected Peter's tag from an off list conversation.

 kernel/events/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/events/core.c +3 -3
index ac70d68217b6..4ee151cd2c6d 100644
@@ -8422,7 +8422,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 	pte_t *ptep, pte;
 
 	pgdp = pgd_offset(mm, addr);
-	pgd = READ_ONCE(*pgdp);
+	pgd = pgdp_get(pgdp);
 	if (pgd_none(pgd))
 		return 0;
 
@@ -8430,7 +8430,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 		return pgd_leaf_size(pgd);
 
 	p4dp = p4d_offset_lockless(pgdp, pgd, addr);
-	p4d = READ_ONCE(*p4dp);
+	p4d = p4dp_get(p4dp);
 	if (!p4d_present(p4d))
 		return 0;
 
@@ -8438,7 +8438,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 		return p4d_leaf_size(p4d);
 
 	pudp = pud_offset_lockless(p4dp, p4d, addr);
-	pud = READ_ONCE(*pudp);
+	pud = pudp_get(pudp);
 	if (!pud_present(pud))
 		return 0;
 
Signature · 1 line
2.30.2
Acked-by on v1 1/1
#1 lore raw
Quoted 22 lines · Anshuman Khandual

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

Quoted 1 line

---

Signature · 3 lines
Cheers,

David
Acked-by on v1 1/1
#2 lore raw
In reply to Anshuman Khandual
Quoted 11 lines · On Fri, 27 Feb 2026 06:27:44 +0000 Anshuman Khandual…

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

Quoted 11 lines

Thanks,
SJ

[...]

#3 lore raw
In reply to Anshuman Khandual
Quoted 57 lines · Anshuman Khandual

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

---
This patch applies both on v7.0-rc1 and mm-unstable.

Part of the D128 series but independent. Hence could be considered on its own.

https://lore.kernel.org/all/[email protected]/

Collected Peter's tag from an off list conversation.

 kernel/events/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/events/core.c +2 -2
index ac70d68217b6..4ee151cd2c6d 100644
@@ -8422,7 +8422,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 	pte_t *ptep, pte;
 
 	pgdp = pgd_offset(mm, addr);
-	pgd = READ_ONCE(*pgdp);
+	pgd = pgdp_get(pgdp);
 	if (pgd_none(pgd))
 		return 0;
 
@@ -8430,7 +8430,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 		return pgd_leaf_size(pgd);
 
 	p4dp = p4d_offset_lockless(pgdp, pgd, addr);
-	p4d = READ_ONCE(*p4dp);
+	p4d = p4dp_get(p4dp);
 	if (!p4d_present(p4d))
 		return 0;
 

kernel/events/core.c static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr) · line 8444

Quoted 8 lines
kernel/events/core.c +1 -1
@@ -8438,7 +8438,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 		return p4d_leaf_size(p4d);
 
 	pudp = pud_offset_lockless(p4dp, p4d, addr);
-	pud = READ_ONCE(*pudp);
+	pud = pudp_get(pudp);
 	if (!pud_present(pud))
 		return 0;
 

Don't see this patch in next-20260306. Is not this being picked for testing ?

#4 lore raw
In reply to Anshuman Khandual
Quoted 22 lines · Anshuman Khandual

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

Quoted 8 lines

---
This patch applies both on v7.0-rc1 and mm-unstable.

Part of the D128 series but independent. Hence could be considered on its own.

https://lore.kernel.org/all/[email protected]/

Collected Peter's tag from an off list conversation.

Gentle ping.

Still don't see this patch in latest next-20260406. Hence just wondering which tree and branch this patch is being picked up ?

Thank you

- Anshuman

Quoted 35 lines
 kernel/events/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/events/core.c +3 -3
index ac70d68217b6..4ee151cd2c6d 100644
@@ -8422,7 +8422,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 	pte_t *ptep, pte;
 
 	pgdp = pgd_offset(mm, addr);
-	pgd = READ_ONCE(*pgdp);
+	pgd = pgdp_get(pgdp);
 	if (pgd_none(pgd))
 		return 0;
 
@@ -8430,7 +8430,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 		return pgd_leaf_size(pgd);
 
 	p4dp = p4d_offset_lockless(pgdp, pgd, addr);
-	p4d = READ_ONCE(*p4dp);
+	p4d = p4dp_get(p4dp);
 	if (!p4d_present(p4d))
 		return 0;
 
@@ -8438,7 +8438,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 		return p4d_leaf_size(p4d);
 
 	pudp = pud_offset_lockless(p4dp, p4d, addr);
-	pud = READ_ONCE(*pudp);
+	pud = pudp_get(pudp);
 	if (!pud_present(pud))
 		return 0;
 
#5 lore raw
Quoted 30 lines · Anshuman Khandual
Quoted 27 lines · Anshuman Khandual

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

---
This patch applies both on v7.0-rc1 and mm-unstable.

Part of the D128 series but independent. Hence could be considered on its own.

Quoted 8 lines
Quoted 3 lines

https://lore.kernel.org/all/[email protected]/

Collected Peter's tag from an off list conversation.

Gentle ping.

Still don't see this patch in latest next-20260406. Hence just wondering which tree and branch this patch is being picked up ?

It's a trivial change and the last generic code change required for you arm64 D128 change, right?

I would assume this to go through the tip tree, but if Peter agrees we could route this (mm) patch through the MM tree.

Signature · 3 lines
Cheers,

David
#6 lore raw
Quoted 35 lines · David Hildenbrand (Arm)
Quoted 34 lines · Anshuman Khandual
Quoted 30 lines · Anshuman Khandual

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

---
This patch applies both on v7.0-rc1 and mm-unstable.

Part of the D128 series but independent. Hence could be considered on its own.

https://lore.kernel.org/all/[email protected]/

Collected Peter's tag from an off list conversation.

Quoted 7 lines
Quoted 4 lines

Gentle ping.

Still don't see this patch in latest next-20260406. Hence just wondering which tree and branch this patch is being picked up ?

It's a trivial change and the last generic code change required for you arm64 D128 change, right?

Right.

Quoted 4 lines

I would assume this to go through the tip tree, but if Peter agrees we could route this (mm) patch through the MM tree.

Sure

maintainer
#7 lore raw
In reply to David Hildenbrand (Arm)
Quoted 37 lines · David Hildenbrand (Arm)
Quoted 36 lines · Anshuman Khandual
Quoted 22 lines · Anshuman Khandual

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

Quoted 8 lines

---
This patch applies both on v7.0-rc1 and mm-unstable.

Part of the D128 series but independent. Hence could be considered on its own.

https://lore.kernel.org/all/[email protected]/

Collected Peter's tag from an off list conversation.

Gentle ping.

Quoted 8 lines
Quoted 2 lines

Still don't see this patch in latest next-20260406. Hence just wondering which tree and branch this patch is being picked up ?

It's a trivial change and the last generic code change required for you arm64 D128 change, right?

I would assume this to go through the tip tree, but if Peter agrees we could route this (mm) patch through the MM tree.

Right, I thought this was part of a larger series and figured it would ride along with whatever other patches.

If you still want me to pick this up, I can, just state clearly where this ought to go.

#8 lore raw
Quoted 44 lines · Peter Zijlstra
Quoted 43 lines · David Hildenbrand (Arm)
Quoted 30 lines · Anshuman Khandual
Quoted 27 lines · Anshuman Khandual

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

---
This patch applies both on v7.0-rc1 and mm-unstable.

Part of the D128 series but independent. Hence could be considered on its own.

Quoted 8 lines
Quoted 3 lines

https://lore.kernel.org/all/[email protected]/

Collected Peter's tag from an off list conversation.

Gentle ping.

Still don't see this patch in latest next-20260406. Hence just wondering which tree and branch this patch is being picked up ?

It's a trivial change and the last generic code change required for you arm64 D128 change, right?

Quoted 8 lines
Quoted 2 lines

I would assume this to go through the tip tree, but if Peter agrees we could route this (mm) patch through the MM tree.

Right, I thought this was part of a larger series and figured it would ride along with whatever other patches.

If you still want me to pick this up, I can, just state clearly where this ought to go.

It would be great if you could pick this up. Thanks !

maintainer
#9 lore raw
Quoted 1 line · Anshuman Khandual

It would be great if you could pick this up. Thanks !

OK done. Should be in tomorrow's -next I suppose.

#10 lore raw
In reply to Anshuman Khandual
Quoted 6 lines · On Tue, 7 Apr 2026 08:58:46 +0530 Anshuman Khandual…
Quoted 5 lines · Anshuman Khandual

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

Quoted 6 lines
Quoted 5 lines

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

Did you consider enhancing READ_ONCE() to support 128bit accesses on arm64?

David

#11 lore raw
Quoted 9 lines · David Laight
Quoted 6 lines · On Tue, 7 Apr 2026 08:58:46 +0530 Anshuman Khandual…
Quoted 5 lines · Anshuman Khandual

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

Did you consider enhancing READ_ONCE() to support 128bit accesses on arm64?

Yes although it does not really meet all requirements for 128 bit page table access.

#12 lore raw
In reply to Anshuman Khandual
The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     5a84b600050c5f16b8bba25dd0e7aea845880407
Gitweb:        https://git.kernel.org/tip/5a84b600050c5f16b8bba25dd0e7aea845880407
Author:        Anshuman Khandual <[email protected]>
AuthorDate:    Fri, 27 Feb 2026 06:27:44 
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Wed, 08 Apr 2026 13:11:46 +02:00

perf/events: Replace READ_ONCE() with standard pgtable accessors

Replace raw READ_ONCE() dereferences of pgtable entries with corresponding standard page table accessors pxdp_get() in perf_get_pgtable_size(). These accessors default to READ_ONCE() on platforms that don't override them. So there is no functional change on such platforms.

However arm64 platform is being extended to support 128 bit page tables via a new architecture feature i.e FEAT_D128 in which case READ_ONCE() will not provide required single copy atomic access for 128 bit page table entries. Although pxdp_get() accessors can later be overridden on arm64 platform to extend required single copy atomicity support on 128 bit entries.

---
 kernel/events/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/events/core.c +3 -3
index 5eeae86..95d7a3e 100644
@@ -8421,7 +8421,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 	pte_t *ptep, pte;
 
 	pgdp = pgd_offset(mm, addr);
-	pgd = READ_ONCE(*pgdp);
+	pgd = pgdp_get(pgdp);
 	if (pgd_none(pgd))
 		return 0;
 
@@ -8429,7 +8429,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 		return pgd_leaf_size(pgd);
 
 	p4dp = p4d_offset_lockless(pgdp, pgd, addr);
-	p4d = READ_ONCE(*p4dp);
+	p4d = p4dp_get(p4dp);
 	if (!p4d_present(p4d))
 		return 0;
 
@@ -8437,7 +8437,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr)
 		return p4d_leaf_size(p4d);
 
 	pudp = pud_offset_lockless(p4dp, p4d, addr);
-	pud = READ_ONCE(*pudp);
+	pud = pudp_get(pudp);
 	if (!pud_present(pud))
 		return 0;