ANDROID: mm/cma: Introduce vendor hooks for best fit CMA allocation

Introduce vendor hooks for best fit mechanism of
CMA allocation.

Bug: 379357530
Change-Id: I8149b0ba1c69d3482e726b6ff5227e8344aed6aa
Signed-off-by: Bibek Kumar Patro <quic_bibekkum@quicinc.com>
This commit is contained in:
Bibek Kumar Patro
2024-05-16 11:05:58 +05:30
committed by Carlos Llamas
parent 3b8d7fd2b0
commit 7acbeed030
4 changed files with 22 additions and 0 deletions
+1
View File
@@ -76,6 +76,7 @@
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_send_sig_info);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_killed_process);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_arch_set_freq_scale);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_bitmap_find_best_next_area);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_transaction_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_set_priority);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_restore_priority);
+11
View File
@@ -35,6 +35,17 @@ DECLARE_RESTRICTED_HOOK(android_rvh_shmem_allowable_huge_orders,
TP_PROTO(struct inode *inode, pgoff_t index,
struct vm_area_struct *vma, unsigned long *orders),
TP_ARGS(inode, index, vma, orders), 4);
DECLARE_RESTRICTED_HOOK(android_rvh_bitmap_find_best_next_area,
TP_PROTO(unsigned long *bitmap,
unsigned long bitmap_maxno,
unsigned long start,
unsigned int bitmap_count,
unsigned long mask,
unsigned long offset,
unsigned long *bitmap_no,
bool status),
TP_ARGS(bitmap, bitmap_maxno, start, bitmap_count, mask,
offset, bitmap_no, status), 1);
/*
DECLARE_RESTRICTED_HOOK(android_rvh_set_skip_swapcache_flags,
+8
View File
@@ -29,6 +29,7 @@
#include <linux/kmemleak.h>
#include <linux/sched.h>
#include <linux/jiffies.h>
#define CREATE_TRACE_POINTS
#include <trace/events/cma.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/mm.h>
@@ -133,6 +134,8 @@ static void __init cma_activate_area(struct cma *cma)
spin_lock_init(&cma->mem_head_lock);
#endif
android_init_vendor_data(cma, 1);
return;
not_in_zone:
@@ -463,6 +466,11 @@ struct page *__cma_alloc(struct cma *cma, unsigned long count,
bitmap_no = bitmap_find_next_zero_area_off(cma->bitmap,
bitmap_maxno, start, bitmap_count, mask,
offset);
#ifdef CONFIG_ANDROID_VENDOR_OEM_DATA
trace_android_rvh_bitmap_find_best_next_area(cma->bitmap,
bitmap_maxno, start, bitmap_count, mask,
offset, &bitmap_no, cma->android_vendor_data1);
#endif
if (bitmap_no >= bitmap_maxno) {
if ((num_attempts < max_retries) && (ret == -EBUSY)) {
spin_unlock_irq(&cma->lock);
+2
View File
@@ -4,6 +4,7 @@
#include <linux/debugfs.h>
#include <linux/kobject.h>
#include <linux/android_vendor.h>
struct cma_kobject {
struct kobject kobj;
@@ -33,6 +34,7 @@ struct cma {
struct cma_kobject *cma_kobj;
#endif
bool reserve_pages_on_error;
ANDROID_VENDOR_DATA(1);
};
extern struct cma cma_areas[MAX_CMA_AREAS];