From 1b2de5aa2d0c121cea40aa2f529ca929dc13381b Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Thu, 1 Apr 2021 18:25:57 -0700 Subject: [PATCH] ANDROID: mm: cma: add vendor hoook in cma_alloc() Add vendor hook for cma_alloc latency measuring. Bug: 177231781 Signed-off-by: Minchan Kim Change-Id: Ia2dbb26454bd8f03489389b29b9a6c939d3c2bbb Signed-off-by: Richard Chang (cherry picked from commit c6e85ea56baac84818fd5d82dda064ef80eef2f6) --- drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/mm.h | 8 ++++++++ mm/cma.c | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 9b7fb0c4e22d..963b012f0192 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -272,4 +272,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_css_offline); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_css_online); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_free); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_alloc); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_start); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_enable_thermal_genl_check); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index a6f21167a0be..afa3cd6850d0 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -11,6 +11,7 @@ struct oom_control; struct slabinfo; +struct cma; DECLARE_RESTRICTED_HOOK(android_rvh_set_skip_swapcache_flags, TP_PROTO(gfp_t *flags), @@ -21,6 +22,13 @@ DECLARE_RESTRICTED_HOOK(android_rvh_set_gfp_zone_flags, DECLARE_RESTRICTED_HOOK(android_rvh_set_readahead_gfp_mask, TP_PROTO(gfp_t *flags), TP_ARGS(flags), 1); +DECLARE_HOOK(android_vh_cma_alloc_start, + TP_PROTO(s64 *ts), + TP_ARGS(ts)); +DECLARE_HOOK(android_vh_cma_alloc_finish, + TP_PROTO(struct cma *cma, struct page *page, unsigned long count, + unsigned int align, gfp_t gfp_mask, s64 ts), + TP_ARGS(cma, page, count, align, gfp_mask, ts)); DECLARE_HOOK(android_vh_meminfo_proc_show, TP_PROTO(struct seq_file *m), TP_ARGS(m)); diff --git a/mm/cma.c b/mm/cma.c index 36e979162157..e03116e9a3fd 100644 --- a/mm/cma.c +++ b/mm/cma.c @@ -36,6 +36,9 @@ #include #include +#undef CREATE_TRACE_POINTS +#include + #include "cma.h" struct cma cma_areas[MAX_CMA_AREAS]; @@ -440,6 +443,9 @@ struct page *cma_alloc(struct cma *cma, unsigned long count, int ret = -ENOMEM; int num_attempts = 0; int max_retries = 5; + s64 ts; + + trace_android_vh_cma_alloc_start(&ts); if (!cma || !cma->count || !cma->bitmap) goto out; @@ -539,6 +545,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count, pr_debug("%s(): returned %p\n", __func__, page); out: + trace_android_vh_cma_alloc_finish(cma, page, count, align, gfp_mask, ts); if (page) { count_vm_event(CMA_ALLOC_SUCCESS); cma_sysfs_account_success_pages(cma, count);