From 5ec033b0cc6f095f5b08655cca2ddd383b1eebf1 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 Change-Id: I174949bf90a4215a6d27f24abbc7d324a321e662 Signed-off-by: Liujie Xie Signed-off-by: Shaleen Agrawal --- drivers/android/binder.c | 6 ++++-- drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/binder.h | 12 ++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index f8a3d29d4e2c..8deace3ff935 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 @@ -3875,6 +3875,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); @@ -4245,6 +4246,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 fb7552cc8677..0b71af57e459 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -153,6 +153,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cgroup_force_kthread_migration); 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_update_topology_flags_workfn); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_balance_rt); diff --git a/include/trace/hooks/binder.h b/include/trace/hooks/binder.h index 00a59ad62e0a..f52f1be5dfd6 100644 --- a/include/trace/hooks/binder.h +++ b/include/trace/hooks/binder.h @@ -22,9 +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)); #endif /* _TRACE_HOOK_BINDER_H */ /* This part must be outside protection */ #include