ANDROID: vendor_hooks: Add hook for binder_alloc_new_buf_locked

Add hook for binder_alloc_new_buf_locked, which gives the vendor a
choice whether or not this alloc new buf should go on or not.

Bug: 322915513
Change-Id: Ie7f1567dae6dee0fb22b014cd1eacc3308ccb205
Signed-off-by: chenweitao <chenweitao@oppo.com>
This commit is contained in:
chenweitao
2025-03-06 14:57:31 +08:00
committed by Todd Kjos
parent e06f8ae2a9
commit 69297c886b
3 changed files with 16 additions and 0 deletions
+12
View File
@@ -25,6 +25,7 @@
#include <linux/sizes.h>
#include "binder_alloc.h"
#include "binder_trace.h"
#include <trace/hooks/binder.h>
struct list_lru binder_freelist;
@@ -444,8 +445,19 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
struct binder_buffer *buffer;
unsigned long next_used_page;
unsigned long curr_last_page;
bool should_fail = false;
size_t buffer_size;
trace_android_vh_binder_alloc_new_buf_locked(size, &alloc->free_async_space, is_async,
&should_fail);
if (should_fail) {
binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
"%d: binder_alloc_buf failed, not allowed to alloc more async space\n",
alloc->pid);
buffer = ERR_PTR(-EPERM);
goto out;
}
if (is_async && alloc->free_async_space < size) {
binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
"%d: binder_alloc_buf size %zd failed, no async space left\n",
+1
View File
@@ -382,6 +382,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_ioctl_end);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_looper_exited);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_spawn_new_thread);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_has_special_work_ilocked);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_alloc_new_buf_locked);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_preset);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_reply);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_trans);
+3
View File
@@ -26,6 +26,9 @@ DECLARE_HOOK(android_vh_binder_set_priority,
DECLARE_HOOK(android_vh_binder_restore_priority,
TP_PROTO(struct binder_transaction *t, struct task_struct *task),
TP_ARGS(t, task));
DECLARE_HOOK(android_vh_binder_alloc_new_buf_locked,
TP_PROTO(size_t size, size_t *free_async_space, int is_async, bool *should_fail),
TP_ARGS(size, free_async_space, is_async, should_fail));
DECLARE_HOOK(android_vh_binder_wait_for_work,
TP_PROTO(bool do_proc_work, struct binder_thread *tsk, struct binder_proc *proc),
TP_ARGS(do_proc_work, tsk, proc));