diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 945b551621a5..1e3afb2f1253 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -428,6 +428,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_new_page); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_pageout_return_error); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_process_madvise_return_error); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_pageout_bypass); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout_abort); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_pages_prepare_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_pages_ok_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_split_large_folio_bypass); @@ -517,6 +518,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_clear_rwsem_writer_owned); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_read_trylock_failed); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compaction_exit); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compaction_try_to_compact_exit); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compact_finished); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_direct_reclaim_enter); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_direct_reclaim_exit); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_may_oom_exit); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 92439e137ab0..be2d6eaf79bc 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -450,6 +450,12 @@ DECLARE_HOOK(android_vh_mm_may_oom_exit, DECLARE_HOOK(android_vh_calculate_totalreserve_pages, TP_PROTO(bool *skip), TP_ARGS(skip)); +DECLARE_HOOK(android_vh_compact_finished, + TP_PROTO(bool *abort_compact), + TP_ARGS(abort_compact)); +DECLARE_HOOK(android_vh_madvise_cold_or_pageout_abort, + TP_PROTO(struct vm_area_struct *vma, bool *abort_madvise), + TP_ARGS(vma, abort_madvise)); #endif /* _TRACE_HOOK_MM_H */ /* This part must be outside protection */ diff --git a/mm/compaction.c b/mm/compaction.c index c6acec0b1a04..263fd54821bc 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -69,6 +69,11 @@ static inline bool is_via_compact_memory(int order) { return false; } #include #include +#undef CREATE_TRACE_POINTS +#ifndef __GENKSYMS__ +#include +#endif + #define block_start_pfn(pfn, order) round_down(pfn, 1UL << (order)) #define block_end_pfn(pfn, order) ALIGN((pfn) + 1, 1UL << (order)) @@ -2297,6 +2302,7 @@ static enum compact_result __compact_finished(struct compact_control *cc) unsigned int order; const int migratetype = cc->migratetype; int ret; + bool abort_compact = false; /* Compaction run completes if the migrate and free scanner meet */ if (compact_scanners_met(cc)) { @@ -2383,7 +2389,8 @@ static enum compact_result __compact_finished(struct compact_control *cc) } out: - if (cc->contended || fatal_signal_pending(current)) + trace_android_vh_compact_finished(&abort_compact); + if (cc->contended || fatal_signal_pending(current) || abort_compact) ret = COMPACT_CONTENDED; return ret; diff --git a/mm/madvise.c b/mm/madvise.c index 9798fcfda6c8..41d7d3077bbf 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -353,10 +353,12 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, LIST_HEAD(folio_list); bool pageout_anon_only_filter; unsigned int batch_count = 0; + bool abort_madvise = false; int nr; int ret = 0; - if (fatal_signal_pending(current)) + trace_android_vh_madvise_cold_or_pageout_abort(vma, &abort_madvise); + if (fatal_signal_pending(current) || abort_madvise) return -EINTR; trace_android_vh_madvise_pageout_bypass(mm, pageout, &ret);