From 1e13e5d9b9ff6ae1b974eaeb38211d4571422dca Mon Sep 17 00:00:00 2001 From: Liujie Xie Date: Tue, 16 Mar 2021 20:48:42 +0800 Subject: [PATCH] ANDROID: vendor_hooks: Add hooks for improving binder trans Recognize important binder proc & binder thread and improve their sched lantency. Bug: 182952552 Signed-off-by: Liujie Xie Change-Id: I174949bf90a4215a6d27f24abbc7d324a321e662 --- drivers/android/binder.c | 6 ++++-- drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/binder.h | 13 ++++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 75ba2d25f87e..b7de3fb333ad 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -526,7 +526,7 @@ static void binder_wakeup_poll_threads_ilocked(struct binder_proc *proc, thread = rb_entry(n, struct binder_thread, rb_node); if (thread->looper & BINDER_LOOPER_STATE_POLL && binder_available_for_proc_work_ilocked(thread)) { - trace_android_vh_binder_wakeup_ilocked(thread->task); + trace_android_vh_binder_wakeup_ilocked(thread->task, sync, proc); if (sync) wake_up_interruptible_sync(&thread->wait); else @@ -586,7 +586,7 @@ static void binder_wakeup_thread_ilocked(struct binder_proc *proc, assert_spin_locked(&proc->inner_lock); if (thread) { - trace_android_vh_binder_wakeup_ilocked(thread->task); + trace_android_vh_binder_wakeup_ilocked(thread->task, sync, proc); if (sync) wake_up_interruptible_sync(&thread->wait); else @@ -3812,6 +3812,7 @@ static int binder_wait_for_work(struct binder_thread *thread, if (do_proc_work) list_add(&thread->waiting_thread_node, &proc->waiting_threads); + trace_android_vh_binder_wait_for_work(do_proc_work, thread, proc); binder_inner_proc_unlock(proc); schedule(); binder_inner_proc_lock(proc); @@ -4177,6 +4178,7 @@ retry: trd->sender_pid = task_tgid_nr_ns(sender, task_active_pid_ns(current)); + trace_android_vh_sync_txn_recvd(thread->task, t_from->task); } else { trd->sender_pid = 0; } diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 64079e850f2e..4a6972572374 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -184,6 +184,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_syscall_prctl_finished); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_tick); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_wakeup_ignore); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_replace_next_task_fair); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_wait_for_work); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sync_txn_recvd); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_build_sched_domains); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_mutex_list_add); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_unlock_slowpath); diff --git a/include/trace/hooks/binder.h b/include/trace/hooks/binder.h index 92f2eb058276..7306fa156b34 100644 --- a/include/trace/hooks/binder.h +++ b/include/trace/hooks/binder.h @@ -22,10 +22,17 @@ 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)); +struct binder_proc; +struct binder_thread; DECLARE_HOOK(android_vh_binder_wakeup_ilocked, - TP_PROTO(struct task_struct *task), - TP_ARGS(task)); - + TP_PROTO(struct task_struct *task, bool sync, struct binder_proc *proc), + TP_ARGS(task, sync, proc)); +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)); +DECLARE_HOOK(android_vh_sync_txn_recvd, + TP_PROTO(struct task_struct *tsk, struct task_struct *from), + TP_ARGS(tsk, from)); /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_BINDER_H */