diff --git a/drivers/android/binder.c b/drivers/android/binder.c index de439ef0061b..ee475757e24e 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -1834,6 +1834,7 @@ static void binder_free_transaction(struct binder_transaction *t) { struct binder_proc *target_proc = t->to_proc; + trace_android_vh_free_oem_binder_struct(t); if (target_proc) { binder_inner_proc_lock(target_proc); target_proc->outstanding_txns--; @@ -3023,6 +3024,7 @@ static int binder_proc_transaction(struct binder_transaction *t, bool pending_async = false; struct binder_transaction *t_outdated = NULL; bool frozen = false; + bool enqueue_task = true; BUG_ON(!node); binder_node_lock(node); @@ -3056,7 +3058,10 @@ static int binder_proc_transaction(struct binder_transaction *t, binder_transaction_priority(thread, t, node); binder_enqueue_thread_work_ilocked(thread, &t->work); } else if (!pending_async) { - binder_enqueue_work_ilocked(&t->work, &proc->todo); + trace_android_vh_binder_special_task(t, proc, thread, + &t->work, &proc->todo, !oneway, &enqueue_task); + if (enqueue_task) + binder_enqueue_work_ilocked(&t->work, &proc->todo); } else { if ((t->flags & TF_UPDATE_TXN) && frozen) { t_outdated = binder_find_outdated_transaction_ilocked(t, @@ -3069,9 +3074,14 @@ static int binder_proc_transaction(struct binder_transaction *t, proc->outstanding_txns--; } } - binder_enqueue_work_ilocked(&t->work, &node->async_todo); + trace_android_vh_binder_special_task(t, proc, thread, + &t->work, &node->async_todo, !oneway, &enqueue_task); + if (enqueue_task) + binder_enqueue_work_ilocked(&t->work, &node->async_todo); } + trace_android_vh_binder_proc_transaction_finish(proc, t, + thread ? thread->task : NULL, pending_async, !oneway); if (!pending_async) binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */); @@ -3545,6 +3555,7 @@ static void binder_transaction(struct binder_proc *proc, t->buffer->target_node = target_node; t->buffer->clear_on_free = !!(t->flags & TF_CLEAR_BUF); trace_binder_transaction_alloc_buf(t->buffer); + trace_android_vh_alloc_oem_binder_struct(tr, t, target_proc); if (binder_alloc_copy_user_to_buffer( &target_proc->alloc, @@ -4206,10 +4217,14 @@ binder_free_buf(struct binder_proc *proc, struct binder_thread *thread, struct binder_buffer *buffer, bool is_failure) { + bool enqueue_task = true; + bool has_transaction = false; + binder_inner_proc_lock(proc); if (buffer->transaction) { buffer->transaction->buffer = NULL; buffer->transaction = NULL; + has_transaction = true; } binder_inner_proc_unlock(proc); if (buffer->async_transaction && buffer->target_node) { @@ -4225,12 +4240,16 @@ binder_free_buf(struct binder_proc *proc, if (!w) { buf_node->has_async_transaction = false; } else { - binder_enqueue_work_ilocked( - w, &proc->todo); + trace_android_vh_binder_special_task(NULL, proc, thread, w, + &proc->todo, false, &enqueue_task); + if (enqueue_task) + binder_enqueue_work_ilocked(w, &proc->todo); binder_wakeup_proc_ilocked(proc); } binder_node_inner_unlock(buf_node); } + trace_android_vh_binder_buffer_release(proc, thread, buffer, + has_transaction); trace_binder_transaction_buffer_release(buffer); binder_release_entire_buffer(proc, thread, buffer, is_failure); binder_alloc_free_buf(&proc->alloc, buffer); @@ -5243,6 +5262,7 @@ retry: ptr += trsize; trace_binder_transaction_received(t); + trace_android_vh_binder_transaction_received(t, proc, thread, cmd); binder_stat_br(proc, thread, cmd); binder_debug(BINDER_DEBUG_TRANSACTION, "%d:%d %s %d %d:%d, cmd %u size %zd-%zd ptr %016llx-%016llx\n", diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 72e16f34b8d6..f4b7bcc2db7f 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -91,6 +91,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_allow_domain_state); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpuidle_psci_enter); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpuidle_psci_exit); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpufreq_transition); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_proc_transaction_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sync_txn_recvd); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_balance_anon_file_reclaim); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_show_max_freq); @@ -122,6 +123,11 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_isolate_freepages); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_check_panic); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_wait_for_work); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_oem_binder_struct); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_transaction_received); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_oem_binder_struct); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_special_task); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_buffer_release); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_folio_look_around_ref); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_look_around); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_look_around_migrate_folio); diff --git a/include/trace/hooks/binder.h b/include/trace/hooks/binder.h index 459413d397a3..4e2932506de4 100644 --- a/include/trace/hooks/binder.h +++ b/include/trace/hooks/binder.h @@ -14,6 +14,9 @@ struct binder_transaction; struct task_struct; struct binder_thread; struct binder_proc; +struct binder_work; +struct binder_buffer; +struct binder_transaction_data; DECLARE_HOOK(android_vh_binder_transaction_init, TP_PROTO(struct binder_transaction *t), TP_ARGS(t)); @@ -29,6 +32,30 @@ 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_proc_transaction_finish, + TP_PROTO(struct binder_proc *proc, struct binder_transaction *t, + struct task_struct *binder_th_task, bool pending_async, bool sync), + TP_ARGS(proc, t, binder_th_task, pending_async, sync)); +DECLARE_HOOK(android_vh_alloc_oem_binder_struct, + TP_PROTO(struct binder_transaction_data *tr, struct binder_transaction *t, + struct binder_proc *proc), + TP_ARGS(tr, t, proc)); +DECLARE_HOOK(android_vh_binder_transaction_received, + TP_PROTO(struct binder_transaction *t, struct binder_proc *proc, + struct binder_thread *thread, uint32_t cmd), + TP_ARGS(t, proc, thread, cmd)); +DECLARE_HOOK(android_vh_free_oem_binder_struct, + TP_PROTO(struct binder_transaction *t), + TP_ARGS(t)); +DECLARE_HOOK(android_vh_binder_special_task, + TP_PROTO(struct binder_transaction *t, struct binder_proc *proc, + struct binder_thread *thread, struct binder_work *w, + struct list_head *head, bool sync, bool *special_task), + TP_ARGS(t, proc, thread, w, head, sync, special_task)); +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)); #endif /* _TRACE_HOOK_BINDER_H */ /* This part must be outside protection */ #include