From 301e89472f3e00a2f02f1967d77efd051ada37f5 Mon Sep 17 00:00:00 2001 From: Zhuguangqing Date: Tue, 9 Mar 2021 15:47:43 +0800 Subject: [PATCH] ANDROID: Add vendor hook to binder. Add vendor hook to get the binder message for vendor-specific tuning. Bug: 182496370 Signed-off-by: Zhuguangqing Change-Id: Id47e59c4e3ccd07b26eef758ada147b98cd1964e --- drivers/android/binder.c | 4 +++- drivers/android/binder_alloc.c | 2 ++ drivers/android/vendor_hooks.c | 4 ++++ include/trace/hooks/binder.h | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 5f0daa35b68e..b3a87a1eae3d 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -2652,6 +2652,7 @@ static void binder_transaction(struct binder_proc *proc, target_proc = target_thread->proc; target_proc->tmp_ref++; binder_inner_proc_unlock(target_thread->proc); + trace_android_vh_binder_reply(target_proc, proc, thread, tr); } else { if (tr->target.handle) { struct binder_ref *ref; @@ -2704,6 +2705,7 @@ static void binder_transaction(struct binder_proc *proc, goto err_dead_binder; } e->to_node = target_node->debug_id; + trace_android_vh_binder_trans(target_proc, proc, thread, tr); if (security_binder_transaction(proc->tsk, target_proc->tsk) < 0) { return_error = BR_FAILED_REPLY; @@ -5155,7 +5157,7 @@ static int binder_open(struct inode *nodp, struct file *filp) } hlist_add_head(&proc->proc_node, &binder_procs); mutex_unlock(&binder_procs_lock); - + trace_android_vh_binder_preset(&binder_procs, &binder_procs_lock); if (binder_debugfs_dir_entry_proc && !existing_pid) { char strbuf[11]; diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c index 7caf74ad2405..5dc959013ea2 100644 --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c @@ -25,6 +25,7 @@ #include #include "binder_alloc.h" #include "binder_trace.h" +#include struct list_lru binder_alloc_lru; @@ -415,6 +416,7 @@ static struct binder_buffer *binder_alloc_new_buf_locked( alloc->pid, extra_buffers_size); return ERR_PTR(-EINVAL); } + trace_android_vh_binder_alloc_new_buf_locked(size, alloc, is_async); if (is_async && alloc->free_async_space < size + sizeof(struct binder_buffer)) { binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC, diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index d7ee5e4334a2..f3af14c5a0f1 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -223,3 +223,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_account_task_time); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gpio_block_read); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ep_create_wakeup_source); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_timerfd_create); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_alloc_new_buf_locked); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_reply); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_trans); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_preset); diff --git a/include/trace/hooks/binder.h b/include/trace/hooks/binder.h index 7306fa156b34..1599eb613c45 100644 --- a/include/trace/hooks/binder.h +++ b/include/trace/hooks/binder.h @@ -13,6 +13,10 @@ */ struct binder_transaction; struct task_struct; +struct binder_alloc; +struct binder_proc; +struct binder_thread; +struct binder_transaction_data; DECLARE_HOOK(android_vh_binder_transaction_init, TP_PROTO(struct binder_transaction *t), TP_ARGS(t)); @@ -33,6 +37,21 @@ DECLARE_HOOK(android_vh_binder_wait_for_work, DECLARE_HOOK(android_vh_sync_txn_recvd, TP_PROTO(struct task_struct *tsk, struct task_struct *from), TP_ARGS(tsk, from)); +DECLARE_HOOK(android_vh_binder_alloc_new_buf_locked, + TP_PROTO(size_t size, struct binder_alloc *alloc, int is_async), + TP_ARGS(size, alloc, is_async)); +DECLARE_HOOK(android_vh_binder_reply, + TP_PROTO(struct binder_proc *target_proc, struct binder_proc *proc, + struct binder_thread *thread, struct binder_transaction_data *tr), + TP_ARGS(target_proc, proc, thread, tr)); +DECLARE_HOOK(android_vh_binder_trans, + TP_PROTO(struct binder_proc *target_proc, struct binder_proc *proc, + struct binder_thread *thread, struct binder_transaction_data *tr), + TP_ARGS(target_proc, proc, thread, tr)); +DECLARE_HOOK(android_vh_binder_preset, + TP_PROTO(struct hlist_head *hhead, struct mutex *lock), + TP_ARGS(hhead, lock)); + /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_BINDER_H */