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

Anshuman Khandual posted 1 patch 1 month, 1 week ago
There is a newer version of this series
kernel/events/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by Anshuman Khandual 1 month, 1 week ago
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.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
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/20260224051153.3150613-5-anshuman.khandual@arm.com/

Collected Peter's tag from an off list conversation.

 kernel/events/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index ac70d68217b6..4ee151cd2c6d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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;
 
-- 
2.30.2
Re: [PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by Anshuman Khandual 2 days, 7 hours ago

On 27/02/26 11:57 AM, Anshuman Khandual wrote:
> 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.
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: David Hildenbrand <david@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: linux-perf-users@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> 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/20260224051153.3150613-5-anshuman.khandual@arm.com/
> 
> 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
  
> 
>  kernel/events/core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index ac70d68217b6..4ee151cd2c6d 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -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;
>
Re: [PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by David Laight 21 hours ago
On Tue, 7 Apr 2026 08:58:46 +0530
Anshuman Khandual <anshuman.khandual@arm.com> wrote:

> On 27/02/26 11:57 AM, Anshuman Khandual wrote:
> > 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.
>

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

	David
Re: [PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by Anshuman Khandual 8 hours ago
On 08/04/26 6:19 PM, David Laight wrote:
> On Tue, 7 Apr 2026 08:58:46 +0530
> Anshuman Khandual <anshuman.khandual@arm.com> wrote:
> 
>> On 27/02/26 11:57 AM, Anshuman Khandual wrote:
>>> 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.
>>
> 
> 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.
Re: [PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by David Hildenbrand (Arm) 2 days, 3 hours ago
On 4/7/26 05:28, Anshuman Khandual wrote:
> 
> 
> On 27/02/26 11:57 AM, Anshuman Khandual wrote:
>> 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.
>>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: David Hildenbrand <david@kernel.org>
>> Cc: Peter Zijlstra <peterz@infradead.org>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
>> Cc: Namhyung Kim <namhyung@kernel.org>
>> Cc: linux-perf-users@vger.kernel.org
>> Cc: linux-mm@kvack.org
>> Cc: linux-kernel@vger.kernel.org
>> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>> 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/20260224051153.3150613-5-anshuman.khandual@arm.com/
>>
>> 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.

-- 
Cheers,

David
Re: [PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by Peter Zijlstra 2 days, 3 hours ago
On Tue, Apr 07, 2026 at 08:48:22AM +0200, David Hildenbrand (Arm) wrote:
> On 4/7/26 05:28, Anshuman Khandual wrote:
> > 
> > 
> > On 27/02/26 11:57 AM, Anshuman Khandual wrote:
> >> 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.
> >>
> >> Cc: Andrew Morton <akpm@linux-foundation.org>
> >> Cc: David Hildenbrand <david@kernel.org>
> >> Cc: Peter Zijlstra <peterz@infradead.org>
> >> Cc: Ingo Molnar <mingo@redhat.com>
> >> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> >> Cc: Namhyung Kim <namhyung@kernel.org>
> >> Cc: linux-perf-users@vger.kernel.org
> >> Cc: linux-mm@kvack.org
> >> Cc: linux-kernel@vger.kernel.org
> >> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> >> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> >> ---
> >> 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/20260224051153.3150613-5-anshuman.khandual@arm.com/
> >>
> >> 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.

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.
Re: [PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by Anshuman Khandual 23 hours ago

On 07/04/26 12:48 PM, Peter Zijlstra wrote:
> On Tue, Apr 07, 2026 at 08:48:22AM +0200, David Hildenbrand (Arm) wrote:
>> On 4/7/26 05:28, Anshuman Khandual wrote:
>>>
>>>
>>> On 27/02/26 11:57 AM, Anshuman Khandual wrote:
>>>> 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.
>>>>
>>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>>> Cc: David Hildenbrand <david@kernel.org>
>>>> Cc: Peter Zijlstra <peterz@infradead.org>
>>>> Cc: Ingo Molnar <mingo@redhat.com>
>>>> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
>>>> Cc: Namhyung Kim <namhyung@kernel.org>
>>>> Cc: linux-perf-users@vger.kernel.org
>>>> Cc: linux-mm@kvack.org
>>>> Cc: linux-kernel@vger.kernel.org
>>>> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
>>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>>>> ---
>>>> 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/20260224051153.3150613-5-anshuman.khandual@arm.com/
>>>>
>>>> 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.
> 
> 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 !
Re: [PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by Peter Zijlstra 23 hours ago
On Wed, Apr 08, 2026 at 04:28:48PM +0530, Anshuman Khandual wrote:

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

OK done. Should be in tomorrow's -next I suppose.
Re: [PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by Anshuman Khandual 2 days, 3 hours ago
On 07/04/26 12:18 PM, David Hildenbrand (Arm) wrote:
> On 4/7/26 05:28, Anshuman Khandual wrote:
>>
>>
>> On 27/02/26 11:57 AM, Anshuman Khandual wrote:
>>> 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.
>>>
>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>> Cc: David Hildenbrand <david@kernel.org>
>>> Cc: Peter Zijlstra <peterz@infradead.org>
>>> Cc: Ingo Molnar <mingo@redhat.com>
>>> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
>>> Cc: Namhyung Kim <namhyung@kernel.org>
>>> Cc: linux-perf-users@vger.kernel.org
>>> Cc: linux-mm@kvack.org
>>> Cc: linux-kernel@vger.kernel.org
>>> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>>> ---
>>> 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/20260224051153.3150613-5-anshuman.khandual@arm.com/
>>>
>>> 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?

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.
> 

Sure
Re: [PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by Anshuman Khandual 1 month ago
On 27/02/26 11:57 AM, Anshuman Khandual wrote:
> 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.
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: David Hildenbrand <david@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: linux-perf-users@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> 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/20260224051153.3150613-5-anshuman.khandual@arm.com/
> 
> Collected Peter's tag from an off list conversation.
> 
>  kernel/events/core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index ac70d68217b6..4ee151cd2c6d 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -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;
> 

Don't see this patch in next-20260306. Is not this being picked for testing ?
Re: [PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by SeongJae Park 1 month, 1 week ago
On Fri, 27 Feb 2026 06:27:44 +0000 Anshuman Khandual <anshuman.khandual@arm.com> wrote:

> 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.
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: David Hildenbrand <david@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: linux-perf-users@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>

Acked-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

[...]
Re: [PATCH] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by David Hildenbrand (Arm) 1 month, 1 week ago
On 2/27/26 07:27, Anshuman Khandual wrote:
> 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.
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: David Hildenbrand <david@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: linux-perf-users@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David
[tip: perf/core] perf/events: Replace READ_ONCE() with standard pgtable accessors
Posted by tip-bot2 for Anshuman Khandual 23 hours ago
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 <anshuman.khandual@arm.com>
AuthorDate:    Fri, 27 Feb 2026 06:27:44 
Committer:     Peter Zijlstra <peterz@infradead.org>
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.

Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260227062744.2215491-1-anshuman.khandual@arm.com
---
 kernel/events/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 5eeae86..95d7a3e 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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;