Re: [PATCH] mm: page_alloc: allowing mTHP compaction to capture the freed page directly

From: Johannes Weiner
Date: Fri Apr 12 2024 - 11:11:31 EST


On Fri, Apr 12, 2024 at 11:27:04AM +0800, Baolin Wang wrote:
> Currently, compaction_capture() does not allow lower-order allocations to
> directly capture the movable free pages, even though lower-order allocations
> might also be requesting movable pages, that can lead to more compaction
> scanning. And, with the enablement of mTHP, such situations will become more
> common.
>
> Thus allowing lower-order (mTHP) allocations of movable page types directly
> capture the movable free pages can avoid unnecessary compaction scanning,
> meanwhile that won't pollute the movable pageblock. With testing 1M mTHP
> compaction, it can be seen that compaction scanning is significantly reduced.
>
> mm-unstable patched
> Ops Compaction pages isolated 116598741.00 120946702.00
> Ops Compaction migrate scanned 1764870054.00 1488621550.00
> Ops Compaction free scanned 7707879039.00 4986299318.00
> Ops Compact scan efficiency 22.90 29.85
> Ops Compaction cost 73797.69 72933.48
>
> Signed-off-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>

Letting a movable request into a partially compacted movable block
seems reasonable.

The only advantage of not doing so that I could imagine would be to
avoid mixing old with new pages, such that reclaim is more likely to
free blocks due to improved LRU grouping. But that seems
far-fetched. Notably, __compact_finished() will also stop once the
requested MOVABLE order becomes available; so not capturing at that
point likely just results in stolen work and compaction restarts.

Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>