mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:24:47 +01:00
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>
This commit is contained in:
parent
5747435e0f
commit
01152bd2e4
3 changed files with 19 additions and 23 deletions
|
|
@ -444,8 +444,8 @@ extern struct page *alloc_contig_pages_noprof(unsigned long nr_pages, gfp_t gfp_
|
||||||
int nid, nodemask_t *nodemask);
|
int nid, nodemask_t *nodemask);
|
||||||
#define alloc_contig_pages(...) alloc_hooks(alloc_contig_pages_noprof(__VA_ARGS__))
|
#define alloc_contig_pages(...) alloc_hooks(alloc_contig_pages_noprof(__VA_ARGS__))
|
||||||
|
|
||||||
#endif
|
|
||||||
void free_contig_range(unsigned long pfn, unsigned long nr_pages);
|
void free_contig_range(unsigned long pfn, unsigned long nr_pages);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_CONTIG_ALLOC
|
#ifdef CONFIG_CONTIG_ALLOC
|
||||||
static inline struct folio *folio_alloc_gigantic_noprof(int order, gfp_t gfp,
|
static inline struct folio *folio_alloc_gigantic_noprof(int order, gfp_t gfp,
|
||||||
|
|
|
||||||
|
|
@ -971,22 +971,26 @@ static unsigned long __init get_random_vaddr(void)
|
||||||
return random_vaddr;
|
return random_vaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __init
|
||||||
|
debug_vm_pgtable_free_huge_page(struct pgtable_debug_args *args,
|
||||||
|
unsigned long pfn, int order)
|
||||||
|
{
|
||||||
|
#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)
|
static void __init destroy_args(struct pgtable_debug_args *args)
|
||||||
{
|
{
|
||||||
struct page *page = NULL;
|
|
||||||
|
|
||||||
/* Free (huge) page */
|
/* Free (huge) page */
|
||||||
if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
|
if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
|
||||||
has_transparent_pud_hugepage() &&
|
has_transparent_pud_hugepage() &&
|
||||||
args->pud_pfn != ULONG_MAX) {
|
args->pud_pfn != ULONG_MAX) {
|
||||||
if (args->is_contiguous_page) {
|
debug_vm_pgtable_free_huge_page(args, args->pud_pfn, HPAGE_PUD_ORDER);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
args->pud_pfn = ULONG_MAX;
|
args->pud_pfn = ULONG_MAX;
|
||||||
args->pmd_pfn = ULONG_MAX;
|
args->pmd_pfn = ULONG_MAX;
|
||||||
args->pte_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) &&
|
if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
|
||||||
has_transparent_hugepage() &&
|
has_transparent_hugepage() &&
|
||||||
args->pmd_pfn != ULONG_MAX) {
|
args->pmd_pfn != ULONG_MAX) {
|
||||||
if (args->is_contiguous_page) {
|
debug_vm_pgtable_free_huge_page(args, args->pmd_pfn, HPAGE_PMD_ORDER);
|
||||||
free_contig_range(args->pmd_pfn, (1 << HPAGE_PMD_ORDER));
|
|
||||||
} else {
|
|
||||||
page = pfn_to_page(args->pmd_pfn);
|
|
||||||
__free_pages(page, HPAGE_PMD_ORDER);
|
|
||||||
}
|
|
||||||
|
|
||||||
args->pmd_pfn = ULONG_MAX;
|
args->pmd_pfn = ULONG_MAX;
|
||||||
args->pte_pfn = ULONG_MAX;
|
args->pte_pfn = ULONG_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->pte_pfn != ULONG_MAX) {
|
if (args->pte_pfn != ULONG_MAX) {
|
||||||
page = pfn_to_page(args->pte_pfn);
|
__free_page(pfn_to_page(args->pte_pfn));
|
||||||
__free_page(page);
|
|
||||||
|
|
||||||
args->pte_pfn = ULONG_MAX;
|
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) &&
|
if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) &&
|
||||||
has_transparent_pud_hugepage()) {
|
has_transparent_pud_hugepage()) {
|
||||||
page = debug_vm_pgtable_alloc_huge_page(args,
|
page = debug_vm_pgtable_alloc_huge_page(args, HPAGE_PUD_ORDER);
|
||||||
HPAGE_PUD_SHIFT - PAGE_SHIFT);
|
|
||||||
if (page) {
|
if (page) {
|
||||||
args->pud_pfn = page_to_pfn(page);
|
args->pud_pfn = page_to_pfn(page);
|
||||||
args->pmd_pfn = args->pud_pfn;
|
args->pmd_pfn = args->pud_pfn;
|
||||||
|
|
|
||||||
|
|
@ -7255,7 +7255,6 @@ retry:
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_CONTIG_ALLOC */
|
|
||||||
|
|
||||||
void free_contig_range(unsigned long pfn, unsigned long nr_pages)
|
void free_contig_range(unsigned long pfn, unsigned long nr_pages)
|
||||||
{
|
{
|
||||||
|
|
@ -7282,6 +7281,7 @@ void free_contig_range(unsigned long pfn, unsigned long nr_pages)
|
||||||
WARN(count != 0, "%lu pages are still in use!\n", count);
|
WARN(count != 0, "%lu pages are still in use!\n", count);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(free_contig_range);
|
EXPORT_SYMBOL(free_contig_range);
|
||||||
|
#endif /* CONFIG_CONTIG_ALLOC */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Effectively disable pcplists for the zone by setting the high limit to 0
|
* Effectively disable pcplists for the zone by setting the high limit to 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue