ANDROID: mm/cma: add vendor_hook in cma_alloc for retries

Add a vendor hook in the cma alloc for the allocation retries that can
be used by clients to control the number of retries before returning.

Bug: 242836407
Change-Id: Iccff0ac2a926d449da5af64086463bd8d93340fc
Signed-off-by: Charan Teja Kalla <quic_charante@quicinc.com>
This commit is contained in:
Charan Teja Kalla
2022-08-10 11:43:12 +05:30
committed by Todd Kjos
parent 8022d8faf6
commit 6f0ba6ad99
3 changed files with 10 additions and 0 deletions

View File

@@ -404,6 +404,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_cpu_resume);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_hib_resume_bdev);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_dma_buf_stats_teardown);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_retry);
/*
* For type visibility

View File

@@ -84,6 +84,9 @@ DECLARE_HOOK(android_vh_mmap_region,
DECLARE_HOOK(android_vh_try_to_unmap_one,
TP_PROTO(struct vm_area_struct *vma, struct page *page, unsigned long addr, bool ret),
TP_ARGS(vma, page, addr, ret));
DECLARE_HOOK(android_vh_cma_alloc_retry,
TP_PROTO(char *name, int *retry),
TP_ARGS(name, retry));
struct mem_cgroup;
DECLARE_HOOK(android_vh_mem_cgroup_alloc,
TP_PROTO(struct mem_cgroup *memcg),

View File

@@ -38,6 +38,11 @@
#include "cma.h"
#undef CREATE_TRACE_POINTS
#ifndef __GENKSYMS__
#include <trace/hooks/mm.h>
#endif
struct cma cma_areas[MAX_CMA_AREAS];
unsigned cma_area_count;
static DEFINE_MUTEX(cma_mutex);
@@ -460,6 +465,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
if (bitmap_count > bitmap_maxno)
goto out;
trace_android_vh_cma_alloc_retry(cma->name, &max_retries);
for (;;) {
spin_lock_irq(&cma->lock);
bitmap_no = bitmap_find_next_zero_area_off(cma->bitmap,