The patch titled Subject: mm/debug_vm_pgtable: use struct vm_pgtable_debug in PGD and P4D modifying tests has been added to the -mm tree. Its filename is mm-debug_vm_pgtable-use-struct-vm_pgtable_debug-in-pgd-and-p4d-modifying-tests.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-debug_vm_pgtable-use-struct-vm_pgtable_debug-in-pgd-and-p4d-modifying-tests.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-debug_vm_pgtable-use-struct-vm_pgtable_debug-in-pgd-and-p4d-modifying-tests.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Gavin Shan <gshan@xxxxxxxxxx> Subject: mm/debug_vm_pgtable: use struct vm_pgtable_debug in PGD and P4D modifying tests This uses struct vm_pgtable_debug in PGD/P4D modifying tests. No allocated huge page is used in these tests. Link: https://lkml.kernel.org/r/20210706061748.161258-11-gshan@xxxxxxxxxx Signed-off-by: Gavin Shan <gshan@xxxxxxxxxx> Cc: Anshuman Khandual <anshuman.khandual@xxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: Chunyu Hu <chuhu@xxxxxxxxxx> Cc: Will Deacon <will@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/debug_vm_pgtable.c | 76 +++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 42 deletions(-) --- a/mm/debug_vm_pgtable.c~mm-debug_vm_pgtable-use-struct-vm_pgtable_debug-in-pgd-and-p4d-modifying-tests +++ a/mm/debug_vm_pgtable.c @@ -520,27 +520,26 @@ static void __init pud_populate_tests(st #endif /* PAGETABLE_PUD_FOLDED */ #ifndef __PAGETABLE_P4D_FOLDED -static void __init p4d_clear_tests(struct mm_struct *mm, p4d_t *p4dp) +static void __init p4d_clear_tests(struct vm_pgtable_debug *debug) { - p4d_t p4d = READ_ONCE(*p4dp); + p4d_t p4d = READ_ONCE(*(debug->p4dp)); - if (mm_pud_folded(mm)) + if (mm_pud_folded(debug->mm)) return; pr_debug("Validating P4D clear\n"); p4d = __p4d(p4d_val(p4d) | RANDOM_ORVALUE); - WRITE_ONCE(*p4dp, p4d); - p4d_clear(p4dp); - p4d = READ_ONCE(*p4dp); + WRITE_ONCE(*(debug->p4dp), p4d); + p4d_clear(debug->p4dp); + p4d = READ_ONCE(*(debug->p4dp)); WARN_ON(!p4d_none(p4d)); } -static void __init p4d_populate_tests(struct mm_struct *mm, p4d_t *p4dp, - pud_t *pudp) +static void __init p4d_populate_tests(struct vm_pgtable_debug *debug) { p4d_t p4d; - if (mm_pud_folded(mm)) + if (mm_pud_folded(debug->mm)) return; pr_debug("Validating P4D populate\n"); @@ -548,34 +547,33 @@ static void __init p4d_populate_tests(st * This entry points to next level page table page. * Hence this must not qualify as p4d_bad(). */ - pud_clear(pudp); - p4d_clear(p4dp); - p4d_populate(mm, p4dp, pudp); - p4d = READ_ONCE(*p4dp); + pud_clear(debug->pudp); + p4d_clear(debug->p4dp); + p4d_populate(debug->mm, debug->p4dp, debug->start_pudp); + p4d = READ_ONCE(*(debug->p4dp)); WARN_ON(p4d_bad(p4d)); } -static void __init pgd_clear_tests(struct mm_struct *mm, pgd_t *pgdp) +static void __init pgd_clear_tests(struct vm_pgtable_debug *debug) { - pgd_t pgd = READ_ONCE(*pgdp); + pgd_t pgd = READ_ONCE(*(debug->pgdp)); - if (mm_p4d_folded(mm)) + if (mm_p4d_folded(debug->mm)) return; pr_debug("Validating PGD clear\n"); pgd = __pgd(pgd_val(pgd) | RANDOM_ORVALUE); - WRITE_ONCE(*pgdp, pgd); - pgd_clear(pgdp); - pgd = READ_ONCE(*pgdp); + WRITE_ONCE(*(debug->pgdp), pgd); + pgd_clear(debug->pgdp); + pgd = READ_ONCE(*(debug->pgdp)); WARN_ON(!pgd_none(pgd)); } -static void __init pgd_populate_tests(struct mm_struct *mm, pgd_t *pgdp, - p4d_t *p4dp) +static void __init pgd_populate_tests(struct vm_pgtable_debug *debug) { pgd_t pgd; - if (mm_p4d_folded(mm)) + if (mm_p4d_folded(debug->mm)) return; pr_debug("Validating PGD populate\n"); @@ -583,23 +581,17 @@ static void __init pgd_populate_tests(st * This entry points to next level page table page. * Hence this must not qualify as pgd_bad(). */ - p4d_clear(p4dp); - pgd_clear(pgdp); - pgd_populate(mm, pgdp, p4dp); - pgd = READ_ONCE(*pgdp); + p4d_clear(debug->p4dp); + pgd_clear(debug->pgdp); + pgd_populate(debug->mm, debug->pgdp, debug->start_p4dp); + pgd = READ_ONCE(*(debug->pgdp)); WARN_ON(pgd_bad(pgd)); } #else /* !__PAGETABLE_P4D_FOLDED */ -static void __init p4d_clear_tests(struct mm_struct *mm, p4d_t *p4dp) { } -static void __init pgd_clear_tests(struct mm_struct *mm, pgd_t *pgdp) { } -static void __init p4d_populate_tests(struct mm_struct *mm, p4d_t *p4dp, - pud_t *pudp) -{ -} -static void __init pgd_populate_tests(struct mm_struct *mm, pgd_t *pgdp, - p4d_t *p4dp) -{ -} +static void __init p4d_clear_tests(struct vm_pgtable_debug *debug) { } +static void __init pgd_clear_tests(struct vm_pgtable_debug *debug) { } +static void __init p4d_populate_tests(struct vm_pgtable_debug *debug) { } +static void __init pgd_populate_tests(struct vm_pgtable_debug *debug) { } #endif /* PAGETABLE_P4D_FOLDED */ static void __init pte_clear_tests(struct vm_pgtable_debug *debug) @@ -1300,12 +1292,12 @@ static int __init debug_vm_pgtable(void) pud_populate_tests(&debug); spin_unlock(ptl); - spin_lock(&mm->page_table_lock); - p4d_clear_tests(mm, p4dp); - pgd_clear_tests(mm, pgdp); - p4d_populate_tests(mm, p4dp, saved_pudp); - pgd_populate_tests(mm, pgdp, saved_p4dp); - spin_unlock(&mm->page_table_lock); + spin_lock(&(debug.mm->page_table_lock)); + p4d_clear_tests(&debug); + pgd_clear_tests(&debug); + p4d_populate_tests(&debug); + pgd_populate_tests(&debug); + spin_unlock(&(debug.mm->page_table_lock)); p4d_free(mm, saved_p4dp); pud_free(mm, saved_pudp); _ Patches currently in -mm which might be from gshan@xxxxxxxxxx are mm-debug_vm_pgtable-introduce-struct-vm_pgtable_debug.patch mm-debug_vm_pgtable-use-struct-vm_pgtable_debug-in-basic-tests.patch mm-debug_vm_pgtable-use-struct-vm_pgtable_debug-in-leaf-and-savewrite-tests.patch mm-debug_vm_pgtable-use-struct-vm_pgtable_debug-in-protnone-and-devmap-tests.patch mm-vm_debug_pgtable-use-struct-vm_pgtable_debug-in-soft_dirty-and-swap-tests.patch mm-debug_vm_pgtable-use-struct-vm_pgtable_debug-in-migration-and-thp-tests.patch mm-debug_vm_pgtable-use-struct-vm_pgtable_debug-in-pte-modifying-tests.patch mm-debug_vm_pgtable-use-struct-vm_pgtable_debug-in-pmd-modifying-tests.patch mm-vm_debug_pgtable-use-struct-vm_pgtable_debug-in-pud-modifying-tests.patch mm-debug_vm_pgtable-use-struct-vm_pgtable_debug-in-pgd-and-p4d-modifying-tests.patch mm-debug_vm_pgtable-remove-unused-code.patch mm-debug_vm_pgtable-fix-corrupted-page-flag.patch