Re: [PATCH 2/6] mm: page_alloc: fix up block types when merging compatible blocks

From: Mel Gorman
Date: Thu Sep 14 2023 - 06:00:39 EST


On Mon, Sep 11, 2023 at 03:41:43PM -0400, Johannes Weiner wrote:
> The buddy allocator coalesces compatible blocks during freeing, but it
> doesn't update the types of the subblocks to match. When an allocation
> later breaks the chunk down again, its pieces will be put on freelists
> of the wrong type. This encourages incompatible page mixing (ask for
> one type, get another), and thus long-term fragmentation.
>
> Update the subblocks when merging a larger chunk, such that a later
> expand() will maintain freelist type hygiene.
>
> v2:
> - remove spurious change_pageblock_range() move (Zi Yan)
>
> Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>

I'm not 100% convinced on the amount of harm this causes but given that
it's a relatively rare condition, I didn't think about the consequences
too deeply. The patch certainly has merit so;

Acked-by: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx>

--
Mel Gorman
SUSE Labs