Re: [PATCH v3 05/10] mm: debug_vm_pgtable: use pgtable_has_pmd_leaves()

Zi Yan
2026-04-09T15:25:40Z

On 8 Apr 2026, at 16:23, Luiz Capitulino wrote:

> debug_vm_pgtable calls has_transparent_hugepage() in multiple places to
> check if PMD-sized pages are supported, use pgtable_has_pmd_leaves()
> instead.
>
> Signed-off-by: Luiz Capitulino <luizcap@redhat.com>
> ---
> mm/debug_vm_pgtable.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index 83cf07269f13..b3e30baaeceb 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -177,7 +177,7 @@ static void __init pmd_basic_tests(struct pgtable_debug_args *args, int idx)
> unsigned long val = idx, *ptr = &val;
> pmd_t pmd;
>
> - if (!has_transparent_hugepage())
> + if (!pgtable_has_pmd_leaves())
> return;
>
> pr_debug("Validating PMD basic (%pGv)\n", ptr);
> @@ -222,7 +222,7 @@ static void __init pmd_advanced_tests(struct pgtable_debug_args *args)
> pmd_t pmd;
> unsigned long vaddr = args->vaddr;
>
> - if (!has_transparent_hugepage())
> + if (!pgtable_has_pmd_leaves())
> return;
>
> page = (args->pmd_pfn != ULONG_MAX) ? pfn_to_page(args->pmd_pfn) : NULL;
> @@ -283,7 +283,7 @@ static void __init pmd_leaf_tests(struct pgtable_debug_args *args)
> {
> pmd_t pmd;
>
> - if (!has_transparent_hugepage())
> + if (!pgtable_has_pmd_leaves())
> return;
>
> pr_debug("Validating PMD leaf\n");
> @@ -688,7 +688,7 @@ static void __init pmd_protnone_tests(struct pgtable_debug_args *args)
> if (!IS_ENABLED(CONFIG_NUMA_BALANCING))
> return;
>
> - if (!has_transparent_hugepage())
> + if (!pgtable_has_pmd_leaves())
> return;
>
> pr_debug("Validating PMD protnone\n");
> @@ -737,7 +737,7 @@ static void __init pmd_soft_dirty_tests(struct pgtable_debug_args *args)
> if (!pgtable_supports_soft_dirty())
> return;
>
> - if (!has_transparent_hugepage())
> + if (!pgtable_has_pmd_leaves())
> return;
>
> pr_debug("Validating PMD soft dirty\n");
> @@ -754,7 +754,7 @@ static void __init pmd_leaf_soft_dirty_tests(struct pgtable_debug_args *args)
> !IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION))
> return;
>
> - if (!has_transparent_hugepage())
> + if (!pgtable_has_pmd_leaves())
> return;
>
> pr_debug("Validating PMD swap soft dirty\n");
> @@ -825,7 +825,7 @@ static void __init pmd_softleaf_tests(struct pgtable_debug_args *args)
> swp_entry_t arch_entry;
> pmd_t pmd1, pmd2;
>
> - if (!has_transparent_hugepage())
> + if (!pgtable_has_pmd_leaves())
> return;
>
> pr_debug("Validating PMD swap\n");
> @@ -906,7 +906,7 @@ static void __init pmd_thp_tests(struct pgtable_debug_args *args)
> {
> pmd_t pmd;
>
> - if (!has_transparent_hugepage())
> + if (!pgtable_has_pmd_leaves())
> return;

Do the above changes require additional IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)
like the ones below? In patch 4, you said IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)
is needed to preserve the existing semantics.

Never mind, since the above code is guarded by #ifdef CONFIG_TRANSPARENT_HUGEPAGE.

Reviewed-by: Zi Yan <ziy@nvidia.com>

>
> pr_debug("Validating PMD based THP\n");
> @@ -997,7 +997,7 @@ static void __init destroy_args(struct pgtable_debug_args *args)
> }
>
> if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
> - has_transparent_hugepage() &&
> + pgtable_has_pmd_leaves() &&
> args->pmd_pfn != ULONG_MAX) {
> debug_vm_pgtable_free_huge_page(args, args->pmd_pfn, HPAGE_PMD_ORDER);
> args->pmd_pfn = ULONG_MAX;
> @@ -1249,7 +1249,7 @@ static int __init init_args(struct pgtable_debug_args *args)
> }
>
> if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
> - has_transparent_hugepage()) {
> + pgtable_has_pmd_leaves()) {
> page = debug_vm_pgtable_alloc_huge_page(args, HPAGE_PMD_ORDER);
> if (page) {
> args->pmd_pfn = page_to_pfn(page);
> --
> 2.53.0

Best Regards,
Yan, Zi