diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 3a00cc61e30a..5dcdb52ee06f 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -337,3 +337,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_special_task); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_free_buf); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compaction_exit); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compaction_try_to_compact_pages_exit); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_alloc_pages_direct_reclaim_enter); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_alloc_pages_direct_reclaim_exit); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_alloc_pages_may_oom_exit); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index e49cc31ea70d..254da451178e 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -141,6 +141,16 @@ DECLARE_HOOK(android_vh_look_around, struct vm_area_struct *vma, int *referenced), TP_ARGS(pvmw, folio, vma, referenced)); +DECLARE_HOOK(android_vh_mm_alloc_pages_direct_reclaim_enter, + TP_PROTO(unsigned int order), + TP_ARGS(order)); +DECLARE_HOOK(android_vh_mm_alloc_pages_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_alloc_pages_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 d5ca46562e88..501d69ac8b95 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4503,6 +4503,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_alloc_pages_may_oom_exit(&oc, *did_some_progress); return NULL; } @@ -4565,6 +4566,7 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order, } out: mutex_unlock(&oom_lock); + trace_android_vh_mm_alloc_pages_may_oom_exit(&oc, *did_some_progress); return page; } @@ -4868,10 +4870,12 @@ __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; + trace_android_vh_mm_alloc_pages_direct_reclaim_enter(order); psi_memstall_enter(&pflags); *did_some_progress = __perform_reclaim(gfp_mask, order, ac); if (unlikely(!(*did_some_progress))) @@ -4889,11 +4893,12 @@ retry: unreserve_highatomic_pageblock(ac, false); drain_all_pages(NULL); drained = true; + ++retry_times; goto retry; } out: psi_memstall_leave(&pflags); - + trace_android_vh_mm_alloc_pages_direct_reclaim_exit(*did_some_progress, retry_times); return page; }