diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 4d2442193033..0d8c43e1138e 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -498,3 +498,6 @@ 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_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 3e1436729ff4..b3454f626d36 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -434,7 +434,16 @@ DECLARE_HOOK(android_vh_filemap_update_page, TP_PROTO(struct address_space *mapping, struct folio *folio, struct file *file), TP_ARGS(mapping, folio, file)); - +DECLARE_HOOK(android_vh_mm_direct_reclaim_enter, + TP_PROTO(unsigned int order), + TP_ARGS(order)); +DECLARE_HOOK(android_vh_mm_direct_reclaim_exit, + TP_PROTO(unsigned long did_some_progress, int retry_times), + TP_ARGS(did_some_progress, retry_times)); +struct oom_control; +DECLARE_HOOK(android_vh_mm_may_oom_exit, + TP_PROTO(struct oom_control *oc, unsigned long did_some_progress), + TP_ARGS(oc, did_some_progress)); #endif /* _TRACE_HOOK_MM_H */ /* This part must be outside protection */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0d653be05eca..16dbe2b33aa7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3925,6 +3925,7 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, if (!mutex_trylock(&oom_lock)) { *did_some_progress = 1; schedule_timeout_uninterruptible(1); + trace_android_vh_mm_may_oom_exit(&oc, *did_some_progress); return NULL; } @@ -3987,6 +3988,7 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, } out: mutex_unlock(&oom_lock); + trace_android_vh_mm_may_oom_exit(&oc, *did_some_progress); return page; } @@ -4275,11 +4277,13 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order, unsigned int alloc_flags, const struct alloc_context *ac, unsigned long *did_some_progress) { + int retry_times = 0; struct page *page = NULL; unsigned long pflags; bool drained = false; bool skip_pcp_drain = false; + trace_android_vh_mm_direct_reclaim_enter(order); psi_memstall_enter(&pflags); *did_some_progress = __perform_reclaim(gfp_mask, order, ac); if (unlikely(!(*did_some_progress))) @@ -4300,11 +4304,12 @@ retry: if (!skip_pcp_drain) drain_all_pages(NULL); drained = true; + ++retry_times; goto retry; } out: psi_memstall_leave(&pflags); - + trace_android_vh_mm_direct_reclaim_exit(*did_some_progress, retry_times); return page; }