mm: page_alloc: trace type pollution from compaction capturing
authorJohannes Weiner <hannes@cmpxchg.org>
Thu, 13 Mar 2025 21:05:33 +0000 (17:05 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 18 Mar 2025 05:07:06 +0000 (22:07 -0700)
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.

Link: https://lkml.kernel.org/r/20250313210647.1314586-3-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Zi Yan <ziy@nvidia.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/page_alloc.c

index 0be1fedd12012dbd7ef7b9ca20404ca92e99d988..5b92b1acda0eed2e29682532ada1760d1cf4f41c 100644 (file)
@@ -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;
 }