[PATCH 2/5] mm: page_alloc: trace type pollution from compaction capturing

From: Johannes Weiner
Date: Thu Mar 13 2025 - 17:07:24 EST


When the page allocator places pages of a certain migratetype into
blocks of another type, it has lasting effects on the ability to
compact and defragment down the line. For improving placement and
compaction, visibility into such events is crucial.

The most common case, allocator fallbacks, is already annotated, but
compaction capturing is also allowed to grab pages of a different
type. Extend the tracepoint to cover this case.

Signed-off-by: Johannes Weiner <hannes@xxxxxxxxxxx>
---
mm/page_alloc.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9b4a5e6dfee9..6f0404941886 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -614,6 +614,10 @@ compaction_capture(struct capture_control *capc, struct page *page,
capc->cc->migratetype != MIGRATE_MOVABLE)
return false;

+ if (migratetype != capc->cc->migratetype)
+ trace_mm_page_alloc_extfrag(page, capc->cc->order, order,
+ capc->cc->migratetype, migratetype);
+
capc->page = page;
return true;
}
--
2.48.1