From a82943cdfbe8acbf3619561f020efec6d4223477 Mon Sep 17 00:00:00 2001 From: Peifeng Li Date: Tue, 15 Mar 2022 21:24:08 +0800 Subject: [PATCH] ANDROID: vendor_hooks: Add hooks to for alloc_contig_range Provide a vendor hook to allow drain_all_pages to be skipped during alloc_contig_range in some cases to avoid delays caused by it in cases when the benefits of draining pcp lists are known to be small. Bug: 224732340 Bug: 234405962 Signed-off-by: Peifeng Li Change-Id: I0a82f668cf985ad5344d666c0c6372a7e61c3798 --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/mm.h | 3 +++ mm/page_alloc.c | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index da4785ee96f6..4804838cfd57 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -211,6 +211,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_balance_anon_file_reclaim); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_show_max_freq); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_referenced_check_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_drain_all_pages_bypass); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_drain_all_pages_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_task); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_after_enqueue_task); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_after_dequeue_task); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 8d19a85e242d..472aed6f2542 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -30,6 +30,9 @@ DECLARE_HOOK(android_vh_drain_all_pages_bypass, int migratetype, unsigned long did_some_progress, bool *bypass), TP_ARGS(gfp_mask, order, alloc_flags, migratetype, did_some_progress, bypass)); +DECLARE_HOOK(android_vh_cma_drain_all_pages_bypass, + TP_PROTO(unsigned int migratetype, bool *bypass), + TP_ARGS(migratetype, bypass)); #endif /* _TRACE_HOOK_MM_H */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 5c08e0f955e1..975888913533 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -9155,6 +9155,7 @@ int alloc_contig_range(unsigned long start, unsigned long end, unsigned long outer_start, outer_end; unsigned int order; int ret = 0; + bool skip_drain_all_pages = false; struct compact_control cc = { .nr_migratepages = 0, @@ -9197,7 +9198,10 @@ int alloc_contig_range(unsigned long start, unsigned long end, if (ret) return ret; - drain_all_pages(cc.zone); + trace_android_vh_cma_drain_all_pages_bypass(migratetype, + &skip_drain_all_pages); + if (skip_drain_all_pages) + drain_all_pages(cc.zone); /* * In case of -EBUSY, we'd like to know which page causes problem.