Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: debug_vm_pgtable: add debug_vm_pgtable_free_huge_page()

Patch series "mm: hugetlb: allocate frozen gigantic folio", v6.

Introduce alloc_contig_frozen_pages() and cma_alloc_frozen_compound()
which avoid atomic operation about page refcount, and then convert to
allocate frozen gigantic folio by the new helpers in hugetlb to cleanup
the alloc_gigantic_folio().


This patch (of 6):

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.

Link: https://lkml.kernel.org/r/20260109093136.1491549-2-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Jane Chu <jane.chu@oracle.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kefeng Wang and committed by
Andrew Morton
01152bd2 5747435e

+19 -23
+1 -1
include/linux/gfp.h
··· 444 444 int nid, nodemask_t *nodemask); 445 445 #define alloc_contig_pages(...) alloc_hooks(alloc_contig_pages_noprof(__VA_ARGS__)) 446 446 447 - #endif 448 447 void free_contig_range(unsigned long pfn, unsigned long nr_pages); 448 + #endif 449 449 450 450 #ifdef CONFIG_CONTIG_ALLOC 451 451 static inline struct folio *folio_alloc_gigantic_noprof(int order, gfp_t gfp,
+17 -21
mm/debug_vm_pgtable.c
··· 971 971 return random_vaddr; 972 972 } 973 973 974 + static void __init 975 + debug_vm_pgtable_free_huge_page(struct pgtable_debug_args *args, 976 + unsigned long pfn, int order) 977 + { 978 + #ifdef CONFIG_CONTIG_ALLOC 979 + if (args->is_contiguous_page) { 980 + free_contig_range(pfn, 1 << order); 981 + return; 982 + } 983 + #endif 984 + __free_pages(pfn_to_page(pfn), order); 985 + } 986 + 974 987 static void __init destroy_args(struct pgtable_debug_args *args) 975 988 { 976 - struct page *page = NULL; 977 - 978 989 /* Free (huge) page */ 979 990 if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && 980 991 has_transparent_pud_hugepage() && 981 992 args->pud_pfn != ULONG_MAX) { 982 - if (args->is_contiguous_page) { 983 - free_contig_range(args->pud_pfn, 984 - (1 << (HPAGE_PUD_SHIFT - PAGE_SHIFT))); 985 - } else { 986 - page = pfn_to_page(args->pud_pfn); 987 - __free_pages(page, HPAGE_PUD_SHIFT - PAGE_SHIFT); 988 - } 989 - 993 + debug_vm_pgtable_free_huge_page(args, args->pud_pfn, HPAGE_PUD_ORDER); 990 994 args->pud_pfn = ULONG_MAX; 991 995 args->pmd_pfn = ULONG_MAX; 992 996 args->pte_pfn = ULONG_MAX; ··· 999 995 if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && 1000 996 has_transparent_hugepage() && 1001 997 args->pmd_pfn != ULONG_MAX) { 1002 - if (args->is_contiguous_page) { 1003 - free_contig_range(args->pmd_pfn, (1 << HPAGE_PMD_ORDER)); 1004 - } else { 1005 - page = pfn_to_page(args->pmd_pfn); 1006 - __free_pages(page, HPAGE_PMD_ORDER); 1007 - } 1008 - 998 + debug_vm_pgtable_free_huge_page(args, args->pmd_pfn, HPAGE_PMD_ORDER); 1009 999 args->pmd_pfn = ULONG_MAX; 1010 1000 args->pte_pfn = ULONG_MAX; 1011 1001 } 1012 1002 1013 1003 if (args->pte_pfn != ULONG_MAX) { 1014 - page = pfn_to_page(args->pte_pfn); 1015 - __free_page(page); 1004 + __free_page(pfn_to_page(args->pte_pfn)); 1016 1005 1017 1006 args->pte_pfn = ULONG_MAX; 1018 1007 } ··· 1239 1242 */ 1240 1243 if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && 1241 1244 has_transparent_pud_hugepage()) { 1242 - page = debug_vm_pgtable_alloc_huge_page(args, 1243 - HPAGE_PUD_SHIFT - PAGE_SHIFT); 1245 + page = debug_vm_pgtable_alloc_huge_page(args, HPAGE_PUD_ORDER); 1244 1246 if (page) { 1245 1247 args->pud_pfn = page_to_pfn(page); 1246 1248 args->pmd_pfn = args->pud_pfn;
+1 -1
mm/page_alloc.c
··· 7255 7255 } 7256 7256 return NULL; 7257 7257 } 7258 - #endif /* CONFIG_CONTIG_ALLOC */ 7259 7258 7260 7259 void free_contig_range(unsigned long pfn, unsigned long nr_pages) 7261 7260 { ··· 7281 7282 WARN(count != 0, "%lu pages are still in use!\n", count); 7282 7283 } 7283 7284 EXPORT_SYMBOL(free_contig_range); 7285 + #endif /* CONFIG_CONTIG_ALLOC */ 7284 7286 7285 7287 /* 7286 7288 * Effectively disable pcplists for the zone by setting the high limit to 0