Re: [PATCH v2 1/3] mm/page_alloc: Optimize free_contig_range()
From: Vlastimil Babka (SUSE)
Date: Fri Mar 20 2026 - 04:20:48 EST
On 3/19/26 23:07, David Hildenbrand (Arm) wrote:
>>> the allocation of non-compound order>0, like you suggested in 3, we basically
>>
>> I suggested we'd take it away in the sense of not producing order>0 where
>> head is refcounted, tails are not, and it's not a compound page. I'd rather
>> have an API that applies split_page() before and returns it as order-0
>> refcounted pages, but not the intermediate order>0 non-compound anymore.
>
> Are you talking about external API or internal API?
In this case of alloc+split, external, and that would make sense to me.
In case of freeing, the current free_pages(order>0) is also external and I
would prefer not to augment it for this free_contig_range() usecase.
> Regarding external interface: I think the crucial part is that an
> external interface (free_contig_range) should always get a range of
> individual order-0 pages: neither compound nor non-compound order > 0.
Ack.
> The individual order-0 pages can either be frozen or refcounted
> (depending on the interface).
Ack.
> Regarding internal interface: To me that implies that FPI_PREPARED will
> never ever have to do any kind of "subpage" (page) free_pages_prepare()
> checks. It must already have been performed on all order-0 pages.
>
> So the TODO should indeed be dropped.
Agreed. But maybe I misunderstood Zi, so that's why I tried to add so much
detail about what I mean by what.
> I'm not sure I understood whether you think using the
> __free_frozen_pages() with order > 0 is okay, or whether we need a
> different (internal) interface.
I think this is fine. But I agree with you above that this assumes
FPI_PREPARED and will not have to deal with subpages.