From: Wandun Chen <[email protected]> Add a tracepoint that fires once per folio successfully isolated by isolate_migratepages_block(), recording the pfn, isolation mode and the folio flags. Knowing these makes it easier to debug unexpected isolation, such as mlocked or unevictable folios showing up on PREEMPT_RT kernels [1].
Inspired-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Wandun Chen <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ [1] --- include/trace/events/compaction.h | 26 ++++++++++++++++++++++++++ mm/compaction.c | 2 ++ 2 files changed, 28 insertions(+) diff --git a/include/trace/events/compaction.h b/include/trace/events/compaction.h index d05759d18538..8b8b3ec0f324 100644 --- a/include/trace/events/compaction.h +++ b/include/trace/events/compaction.h @@ -76,6 +76,32 @@ DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_fast_isolate_freepage ); #ifdef CONFIG_COMPACTION +TRACE_EVENT(mm_compaction_isolate_folio, + + TP_PROTO(unsigned long pfn, + isolate_mode_t mode, + unsigned long flags), + + TP_ARGS(pfn, mode, flags), + + TP_STRUCT__entry( + __field(unsigned long, pfn) + __field(isolate_mode_t, mode) + __field(unsigned long, flags) + ), + + TP_fast_assign( + __entry->pfn = pfn; + __entry->mode = mode; + __entry->flags = flags; + ), + + TP_printk("pfn=0x%lx mode=0x%x flags=%s", + __entry->pfn, + __entry->mode, + show_page_flags(__entry->flags & PAGEFLAGS_MASK)) +); + TRACE_EVENT(mm_compaction_migratepages, TP_PROTO(unsigned int nr_migratepages, diff --git a/mm/compaction.c b/mm/compaction.c index 7e07b792bcb5..007d5e00a8ae 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1223,6 +1223,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, isolate_success: list_add(&folio->lru, &cc->migratepages); isolate_success_no_list: + trace_mm_compaction_isolate_folio(folio_pfn(folio), mode, + folio->flags.f); cc->nr_migratepages += folio_nr_pages(folio); nr_isolated += folio_nr_pages(folio); nr_scanned += folio_nr_pages(folio) - 1; -- 2.43.0
