Re: [PATCH v2 6/9] mm: page_alloc: add alloc_contig_frozen_pages()

Matthew Wilcox
2025-09-09T18:55:52Z

On Tue, Sep 02, 2025 at 08:48:17PM +0800, Kefeng Wang wrote:
> Introduce a ACR_FLAGS_FROZEN flags to indicate that we want to
> allocate a frozen compound pages by alloc_contig_range(), also
> provide alloc_contig_frozen_pages() to allocate pages without
> incrementing their refcount, which may be beneficial to some
> users (eg hugetlb).

No, this is not the way to do it. We're moving towards a future where
pages don't have refcounts (their owning structs eg folios may have a
refcount, but struct page does not have a refcount). So work towards
that; if you need to keep compatibility with some users, then by all
means keep alloc_contig_range_noprof() as a wrapper that calls
alloc_contig_range_frozen_noprof() and then calls set_page_refcounted()
if alloc_contig_range_frozen_noprof() does not return NULL. But I'd
be looking to see if alloc_contig_range_noprof() can always return a
non-refcounted page.