ANDROID: mm: cma: add vendor hoook in cma_alloc()

Add vendor hook for cma_alloc latency measuring.

Bug: 177231781
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ia2dbb26454bd8f03489389b29b9a6c939d3c2bbb
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit c6e85ea56b)
This commit is contained in:
Minchan Kim
2021-04-01 18:25:57 -07:00
committed by Richard Chang
parent e845c965ad
commit 1b2de5aa2d
3 changed files with 17 additions and 0 deletions

View File

@@ -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_css_online);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_free); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_free);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_alloc); 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); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_enable_thermal_genl_check);

View File

@@ -11,6 +11,7 @@
struct oom_control; struct oom_control;
struct slabinfo; struct slabinfo;
struct cma;
DECLARE_RESTRICTED_HOOK(android_rvh_set_skip_swapcache_flags, DECLARE_RESTRICTED_HOOK(android_rvh_set_skip_swapcache_flags,
TP_PROTO(gfp_t *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, DECLARE_RESTRICTED_HOOK(android_rvh_set_readahead_gfp_mask,
TP_PROTO(gfp_t *flags), TP_PROTO(gfp_t *flags),
TP_ARGS(flags), 1); 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, DECLARE_HOOK(android_vh_meminfo_proc_show,
TP_PROTO(struct seq_file *m), TP_PROTO(struct seq_file *m),
TP_ARGS(m)); TP_ARGS(m));

View File

@@ -36,6 +36,9 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <trace/events/cma.h> #include <trace/events/cma.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/mm.h>
#include "cma.h" #include "cma.h"
struct cma cma_areas[MAX_CMA_AREAS]; 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 ret = -ENOMEM;
int num_attempts = 0; int num_attempts = 0;
int max_retries = 5; int max_retries = 5;
s64 ts;
trace_android_vh_cma_alloc_start(&ts);
if (!cma || !cma->count || !cma->bitmap) if (!cma || !cma->count || !cma->bitmap)
goto out; goto out;
@@ -539,6 +545,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
pr_debug("%s(): returned %p\n", __func__, page); pr_debug("%s(): returned %p\n", __func__, page);
out: out:
trace_android_vh_cma_alloc_finish(cma, page, count, align, gfp_mask, ts);
if (page) { if (page) {
count_vm_event(CMA_ALLOC_SUCCESS); count_vm_event(CMA_ALLOC_SUCCESS);
cma_sysfs_account_success_pages(cma, count); cma_sysfs_account_success_pages(cma, count);