From: Sid Kumar <sidhartha.kumar@oracle.com>
To: Kefeng Wang <wangkefeng.wang@huawei.com>,
Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>,
Oscar Salvador <osalvador@suse.de>,
Muchun Song <muchun.song@linux.dev>,
linux-mm@kvack.org
Cc: jane.chu@oracle.com, Zi Yan <ziy@nvidia.com>,
Vlastimil Babka <vbabka@suse.cz>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH v5 1/6] mm: debug_vm_pgtable: add debug_vm_pgtable_free_huge_page()
Date: Fri, 2 Jan 2026 12:51:11 -0600 [thread overview]
Message-ID: <e9f0f249-10cc-4c78-b461-fa7e05a24c2b@oracle.com> (raw)
In-Reply-To: <20251230072422.265265-2-wangkefeng.wang@huawei.com>
On 12/30/25 1:24 AM, Kefeng Wang wrote:
> Add a new helper to free huge page to be consistency to
> debug_vm_pgtable_alloc_huge_page(), and use HPAGE_PUD_ORDER
> instead of open-code.
>
> Also move the free_contig_range() under CONFIG_ALLOC_CONTIG
> since all caller are built with CONFIG_ALLOC_CONTIG.
>
> Acked-by: David Hildenbrand <david@redhat.com>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Reviewed-by: Muchun Song <muchun.song@linux.dev>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
> include/linux/gfp.h | 2 +-
> mm/debug_vm_pgtable.c | 38 +++++++++++++++++---------------------
> mm/page_alloc.c | 2 +-
> 3 files changed, 19 insertions(+), 23 deletions(-)
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> diff --git a/include/linux/gfp.h b/include/linux/gfp.h
> index b155929af5b1..ea053f1cfa16 100644
> --- a/include/linux/gfp.h
> +++ b/include/linux/gfp.h
> @@ -438,8 +438,8 @@ extern struct page *alloc_contig_pages_noprof(unsigned long nr_pages, gfp_t gfp_
> int nid, nodemask_t *nodemask);
> #define alloc_contig_pages(...) alloc_hooks(alloc_contig_pages_noprof(__VA_ARGS__))
>
> -#endif
> void free_contig_range(unsigned long pfn, unsigned long nr_pages);
> +#endif
>
> #ifdef CONFIG_CONTIG_ALLOC
> static inline struct folio *folio_alloc_gigantic_noprof(int order, gfp_t gfp,
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index ae9b9310d96f..83cf07269f13 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -971,22 +971,26 @@ static unsigned long __init get_random_vaddr(void)
> return random_vaddr;
> }
>
> -static void __init destroy_args(struct pgtable_debug_args *args)
> +static void __init
> +debug_vm_pgtable_free_huge_page(struct pgtable_debug_args *args,
> + unsigned long pfn, int order)
> {
> - struct page *page = NULL;
> +#ifdef CONFIG_CONTIG_ALLOC
> + if (args->is_contiguous_page) {
> + free_contig_range(pfn, 1 << order);
> + return;
> + }
> +#endif
> + __free_pages(pfn_to_page(pfn), order);
> +}
>
> +static void __init destroy_args(struct pgtable_debug_args *args)
> +{
> /* Free (huge) page */
> if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
> has_transparent_pud_hugepage() &&
> args->pud_pfn != ULONG_MAX) {
> - if (args->is_contiguous_page) {
> - free_contig_range(args->pud_pfn,
> - (1 << (HPAGE_PUD_SHIFT - PAGE_SHIFT)));
> - } else {
> - page = pfn_to_page(args->pud_pfn);
> - __free_pages(page, HPAGE_PUD_SHIFT - PAGE_SHIFT);
> - }
> -
> + debug_vm_pgtable_free_huge_page(args, args->pud_pfn, HPAGE_PUD_ORDER);
> args->pud_pfn = ULONG_MAX;
> args->pmd_pfn = ULONG_MAX;
> args->pte_pfn = ULONG_MAX;
> @@ -995,20 +999,13 @@ static void __init destroy_args(struct pgtable_debug_args *args)
> if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
> has_transparent_hugepage() &&
> args->pmd_pfn != ULONG_MAX) {
> - if (args->is_contiguous_page) {
> - free_contig_range(args->pmd_pfn, (1 << HPAGE_PMD_ORDER));
> - } else {
> - page = pfn_to_page(args->pmd_pfn);
> - __free_pages(page, HPAGE_PMD_ORDER);
> - }
> -
> + debug_vm_pgtable_free_huge_page(args, args->pmd_pfn, HPAGE_PMD_ORDER);
> args->pmd_pfn = ULONG_MAX;
> args->pte_pfn = ULONG_MAX;
> }
>
> if (args->pte_pfn != ULONG_MAX) {
> - page = pfn_to_page(args->pte_pfn);
> - __free_page(page);
> + __free_page(pfn_to_page(args->pte_pfn));
>
> args->pte_pfn = ULONG_MAX;
> }
> @@ -1242,8 +1239,7 @@ static int __init init_args(struct pgtable_debug_args *args)
> */
> if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
> has_transparent_pud_hugepage()) {
> - page = debug_vm_pgtable_alloc_huge_page(args,
> - HPAGE_PUD_SHIFT - PAGE_SHIFT);
> + page = debug_vm_pgtable_alloc_huge_page(args, HPAGE_PUD_ORDER);
> if (page) {
> args->pud_pfn = page_to_pfn(page);
> args->pmd_pfn = args->pud_pfn;
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index a045d728ae0f..206397ed33a7 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -7248,7 +7248,6 @@ struct page *alloc_contig_pages_noprof(unsigned long nr_pages, gfp_t gfp_mask,
> }
> return NULL;
> }
> -#endif /* CONFIG_CONTIG_ALLOC */
>
> void free_contig_range(unsigned long pfn, unsigned long nr_pages)
> {
> @@ -7275,6 +7274,7 @@ void free_contig_range(unsigned long pfn, unsigned long nr_pages)
> WARN(count != 0, "%lu pages are still in use!\n", count);
> }
> EXPORT_SYMBOL(free_contig_range);
> +#endif /* CONFIG_CONTIG_ALLOC */
>
> /*
> * Effectively disable pcplists for the zone by setting the high limit to 0
next prev parent reply other threads:[~2026-01-02 18:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-30 7:24 [PATCH v5 mm-new 0/6] mm: hugetlb: allocate frozen gigantic folio Kefeng Wang
2025-12-30 7:24 ` [PATCH v5 1/6] mm: debug_vm_pgtable: add debug_vm_pgtable_free_huge_page() Kefeng Wang
2026-01-02 18:51 ` Sid Kumar [this message]
2025-12-30 7:24 ` [PATCH v5 2/6] mm: page_alloc: add __split_page() Kefeng Wang
2026-01-02 18:55 ` Sid Kumar
2025-12-30 7:24 ` [PATCH v5 3/6] mm: cma: kill cma_pages_valid() Kefeng Wang
2025-12-30 7:24 ` [PATCH v5 4/6] mm: page_alloc: add alloc_contig_frozen_{range,pages}() Kefeng Wang
2025-12-31 2:57 ` Zi Yan
2026-01-02 21:05 ` Sid Kumar
2025-12-30 7:24 ` [PATCH v5 5/6] mm: cma: add cma_alloc_frozen{_compound}() Kefeng Wang
2025-12-31 2:59 ` Zi Yan
2025-12-30 7:24 ` [PATCH v5 6/6] mm: hugetlb: allocate frozen pages for gigantic allocation Kefeng Wang
2025-12-31 2:50 ` Muchun Song
2025-12-31 3:00 ` Zi Yan
2025-12-30 18:17 ` [PATCH v5 mm-new 0/6] mm: hugetlb: allocate frozen gigantic folio Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e9f0f249-10cc-4c78-b461-fa7e05a24c2b@oracle.com \
--to=sidhartha.kumar@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=jane.chu@oracle.com \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=vbabka@suse.cz \
--cc=wangkefeng.wang@huawei.com \
--cc=willy@infradead.org \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox