From 09c3bee38606d6a34b63f7aa66987c85e5b7b21f Mon Sep 17 00:00:00 2001 From: Zhuguangqing Date: Tue, 9 Mar 2021 15:47:43 +0800 Subject: [PATCH] ANDROID: Add vendor hooks for binder perf tuning Add some hooks in the binder module so that we can do task dependency analysis and statistical work in OEM's module for further optimization. Bug: 235925535 Bug: 281920779 Signed-off-by: Zhuguangqing Change-Id: Id47e59c4e3ccd07b26eef758ada147b98cd1964e Signed-off-by: heshuai1 --- drivers/android/binder.c | 4 +++- drivers/android/vendor_hooks.c | 3 +++ include/trace/hooks/binder.h | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index cf2079ea6165..0fb7611aae70 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -3285,6 +3285,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; @@ -3347,6 +3348,7 @@ static void binder_transaction(struct binder_proc *proc, return_error_line = __LINE__; goto err_invalid_target_handle; } + trace_android_vh_binder_trans(target_proc, proc, thread, tr); if (security_binder_transaction(proc->cred, target_proc->cred) < 0) { binder_txn_error("%d:%d transaction credentials failed\n", @@ -6276,7 +6278,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/vendor_hooks.c b/drivers/android/vendor_hooks.c index c04674169488..c9a1ec2cd5e9 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -362,3 +362,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dma_heap_buffer_alloc_start); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dma_heap_buffer_alloc_end); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_zs_shrinker_adjust); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_zs_shrinker_bypass); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_preset); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_reply); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_trans); diff --git a/include/trace/hooks/binder.h b/include/trace/hooks/binder.h index 4e2932506de4..11795f6e6407 100644 --- a/include/trace/hooks/binder.h +++ b/include/trace/hooks/binder.h @@ -56,6 +56,21 @@ DECLARE_HOOK(android_vh_binder_buffer_release, TP_PROTO(struct binder_proc *proc, struct binder_thread *thread, struct binder_buffer *buffer, bool has_transaction), TP_ARGS(proc, thread, buffer, has_transaction)); +struct binder_proc; +struct binder_thread; +DECLARE_HOOK(android_vh_binder_preset, + TP_PROTO(struct hlist_head *hhead, struct mutex *lock), + TP_ARGS(hhead, lock)); +struct binder_transaction_data; +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)); + #endif /* _TRACE_HOOK_BINDER_H */ /* This part must be outside protection */ #include