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

Johannes Weiner posted 5 patches 9 months, 1 week ago
[PATCH 2/5] mm: page_alloc: trace type pollution from compaction capturing
Posted by Johannes Weiner 9 months, 1 week ago
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@cmpxchg.org>
---
 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
Re: [PATCH 2/5] mm: page_alloc: trace type pollution from compaction capturing
Posted by Zi Yan 9 months, 1 week ago
On 13 Mar 2025, at 17:05, Johannes Weiner wrote:

> 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@cmpxchg.org>
> ---
>  mm/page_alloc.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
Acked-by: Zi Yan <ziy@nvidia.com>

Best Regards,
Yan, Zi