Re: [PATCH 3/6] mm: page_alloc: move free pages when converting block during isolation

From: Vlastimil Babka
Date: Wed Sep 13 2023 - 10:31:18 EST


On 9/11/23 21:41, Johannes Weiner wrote:
> When claiming a block during compaction isolation, move any remaining
> free pages to the correct freelists as well, instead of stranding them
> on the wrong list. Otherwise, this encourages incompatible page mixing
> down the line, and thus long-term fragmentation.
>
> Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>

Reviewed-by: Vlastimil Babka <vbabka@xxxxxxx>

> ---
> mm/page_alloc.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 3db405414174..f6f658c3d394 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2548,9 +2548,12 @@ int __isolate_free_page(struct page *page, unsigned int order)
> * Only change normal pageblocks (i.e., they can merge
> * with others)
> */
> - if (migratetype_is_mergeable(mt))
> + if (migratetype_is_mergeable(mt)) {
> set_pageblock_migratetype(page,
> MIGRATE_MOVABLE);
> + move_freepages_block(zone, page,
> + MIGRATE_MOVABLE, NULL);
> + }
> }
> }
>