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: 364813584
Bug: 242836407
Change-Id: Iccff0ac2a926d449da5af64086463bd8d93340fc
Signed-off-by: Charan Teja Kalla <quic_charante@quicinc.com>
(cherry picked from commit 6f0ba6ad99)
This commit is contained in:
Charan Teja Kalla 2022-08-10 11:43:12 +05:30 committed by Treehugger Robot
parent 16fdc0cae4
commit e1f8da20f9
3 changed files with 10 additions and 0 deletions

View File

@ -541,5 +541,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ogki_kmem_cache_create_usercopy);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_customize_thp_pcp_order);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_customize_thp_gfp_orders);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_init_adjust_zone_wmark);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_retry);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_ksys_umount);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_group_exit);

View File

@ -390,6 +390,9 @@ DECLARE_HOOK(android_vh_customize_thp_gfp_orders,
DECLARE_HOOK(android_vh_init_adjust_zone_wmark,
TP_PROTO(struct zone *zone, u64 interval),
TP_ARGS(zone, interval));
DECLARE_HOOK(android_vh_cma_alloc_retry,
TP_PROTO(char *name, int *retry),
TP_ARGS(name, retry));
DECLARE_HOOK(android_vh_do_group_exit,
TP_PROTO(struct task_struct *tsk),
TP_ARGS(tsk));

View File

@ -39,6 +39,11 @@
#include "internal.h"
#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);
@ -471,6 +476,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,