summaryrefslogtreecommitdiff
path: root/mm/internal.h
diff options
context:
space:
mode:
authorKefeng Wang <wangkefeng.wang@huawei.com>2026-01-09 17:31:34 +0800
committerAndrew Morton <akpm@linux-foundation.org>2026-01-26 20:02:28 -0800
commite0c1326779cc1b8e3a9e30ae273b89202ed4c82c (patch)
tree5a8612e814f36a0d10c656d8f3505eb4b3e685c9 /mm/internal.h
parent6c08cc64d194dc5cc3dfc785517098d3b161c05f (diff)
downloadlinux-next-e0c1326779cc1b8e3a9e30ae273b89202ed4c82c.tar.gz
linux-next-e0c1326779cc1b8e3a9e30ae273b89202ed4c82c.zip
mm: page_alloc: add alloc_contig_frozen_{range,pages}()
In order to allocate given range of pages or allocate compound pages without incrementing their refcount, adding two new helper alloc_contig_frozen_{range,pages}() which may be beneficial to some users (eg hugetlb). The new alloc_contig_{range,pages} only take !__GFP_COMP gfp now, and the free_contig_range() is refactored to only free non-compound pages, the only caller to free compound pages in cma_free_folio() is changed accordingly, and the free_contig_frozen_range() is provided to match the alloc_contig_frozen_range(), which is used to free frozen pages. Link: https://lkml.kernel.org/r/20260109093136.1491549-5-wangkefeng.wang@huawei.com Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com> Reviewed-by: Zi Yan <ziy@nvidia.com> Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> Cc: Brendan Jackman <jackmanb@google.com> Cc: David Hildenbrand <david@redhat.com> Cc: Jane Chu <jane.chu@oracle.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Muchun Song <muchun.song@linux.dev> 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>
Diffstat (limited to 'mm/internal.h')
-rw-r--r--mm/internal.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/mm/internal.h b/mm/internal.h
index 5585059f0209..0623b865ad1a 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -580,6 +580,19 @@ static inline void set_page_refcounted(struct page *page)
set_page_count(page, 1);
}
+static inline void set_pages_refcounted(struct page *page, unsigned long nr_pages)
+{
+ unsigned long pfn = page_to_pfn(page);
+
+ if (PageHead(page)) {
+ set_page_refcounted(page);
+ return;
+ }
+
+ for (; nr_pages--; pfn++)
+ set_page_refcounted(pfn_to_page(pfn));
+}
+
/*
* Return true if a folio needs ->release_folio() calling upon it.
*/