Skip to contentSkip to conversation

mm/debug_vm_pgtable: Replace WRITE_ONCE() with pxd_clear()

PATCH Applied Anshuman Khandual 3 participants 3 messages Feb 27 – Feb 28 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/debug_vm_pgtable: Replace WRITE_ONCE() with pxd_clear()

Replace WRITE_ONCE() with generic pxd_clear() to clear out the page table entries as required. Besides this does not cause any functional change as well.

---
Applies on mm-unstable and tested only on arm64 platform.

 mm/debug_vm_pgtable.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/debug_vm_pgtable.c +2 -2
index 83cf07269f13..23dc3ee09561 100644
@@ -445,7 +445,7 @@ static void __init pmd_huge_tests(struct pgtable_debug_args *args)
 	 * X86 defined pmd_set_huge() verifies that the given
 	 * PMD is not a populated non-leaf entry.
 	 */
-	WRITE_ONCE(*args->pmdp, __pmd(0));
+	pmd_clear(args->pmdp);
 	WARN_ON(!pmd_set_huge(args->pmdp, __pfn_to_phys(args->fixed_pmd_pfn), args->page_prot));
 	WARN_ON(!pmd_clear_huge(args->pmdp));
 	pmd = pmdp_get(args->pmdp);
@@ -465,7 +465,7 @@ static void __init pud_huge_tests(struct pgtable_debug_args *args)
 	 * X86 defined pud_set_huge() verifies that the given
 	 * PUD is not a populated non-leaf entry.
 	 */
-	WRITE_ONCE(*args->pudp, __pud(0));
+	pud_clear(args->pudp);
 	WARN_ON(!pud_set_huge(args->pudp, __pfn_to_phys(args->fixed_pud_pfn), args->page_prot));
 	WARN_ON(!pud_clear_huge(args->pudp));
 	pud = pudp_get(args->pudp);
Signature · 1 line
2.30.2
Acked-by on v1 1/1
#1 lore raw
Quoted 30 lines · Anshuman Khandual

Replace WRITE_ONCE() with generic pxd_clear() to clear out the page table entries as required. Besides this does not cause any functional change as well.

---
Applies on mm-unstable and tested only on arm64 platform.

 mm/debug_vm_pgtable.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/debug_vm_pgtable.c +1 -1
index 83cf07269f13..23dc3ee09561 100644
@@ -445,7 +445,7 @@ static void __init pmd_huge_tests(struct pgtable_debug_args *args)
 	 * X86 defined pmd_set_huge() verifies that the given
 	 * PMD is not a populated non-leaf entry.
 	 */
-	WRITE_ONCE(*args->pmdp, __pmd(0));
+	pmd_clear(args->pmdp);
 	WARN_ON(!pmd_set_huge(args->pmdp, __pfn_to_phys(args->fixed_pmd_pfn), args->page_prot));
 	WARN_ON(!pmd_clear_huge(args->pmdp));
 	pmd = pmdp_get(args->pmdp);

mm/debug_vm_pgtable.c static void __init pud_huge_tests(struct pgtable_debug_args *args) · line 471

Quoted 8 lines
mm/debug_vm_pgtable.c +1 -1
@@ -465,7 +465,7 @@ static void __init pud_huge_tests(struct pgtable_debug_args *args)
 	 * X86 defined pud_set_huge() verifies that the given
 	 * PUD is not a populated non-leaf entry.
 	 */
-	WRITE_ONCE(*args->pudp, __pud(0));
+	pud_clear(args->pudp);
 	WARN_ON(!pud_set_huge(args->pudp, __pfn_to_phys(args->fixed_pud_pfn), args->page_prot));
 	WARN_ON(!pud_clear_huge(args->pudp));
 	pud = pudp_get(args->pudp);

On some architectures, pmd_clear() does not set the pmd to zero.

See s390x as an example:

	set_pmd(pmdp, __pmd(_SEGMENT_ENTRY_EMPTY));

Which results on 0x20 being set.

Maybe we're lucky and all relevant architectures do not have CONFIG_HAVE_ARCH_HUGE_VMAP.

Or maybe it just doesn't matter.

We'll find out :)

Signature · 3 lines
Cheers,

David
#2 lore raw
In reply to Anshuman Khandual
Quoted 10 lines · On Fri, 27 Feb 2026 06:12:04 +0000 Anshuman Khandual…

Replace WRITE_ONCE() with generic pxd_clear() to clear out the page table entries as required. Besides this does not cause any functional change as well.

Thanks,
SJ

[...]