diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 4165922e93ec..f767ceee9c5c 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -1673,6 +1673,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--; @@ -2855,6 +2856,7 @@ static int binder_proc_transaction(struct binder_transaction *t, bool oneway = !!(t->flags & TF_ONE_WAY); bool pending_async = false; struct binder_transaction *t_outdated = NULL; + bool enqueue_task = true; BUG_ON(!node); binder_node_lock(node); @@ -2894,7 +2896,10 @@ static int binder_proc_transaction(struct binder_transaction *t, node->inherit_rt); 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) && proc->is_frozen) { t_outdated = binder_find_outdated_transaction_ilocked(t, @@ -2907,11 +2912,16 @@ 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_end(current, proc->tsk, thread ? thread->task : NULL, t->code, pending_async, !oneway); + 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 */); @@ -3349,6 +3359,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, @@ -3818,6 +3829,9 @@ binder_free_buf(struct binder_proc *proc, struct binder_thread *thread, struct binder_buffer *buffer, bool is_failure) { + bool enqueue_task = true; + + trace_android_vh_binder_free_buf(proc, thread, buffer); binder_inner_proc_lock(proc); if (buffer->transaction) { buffer->transaction->buffer = NULL; @@ -3837,8 +3851,10 @@ 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); @@ -4785,6 +4801,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 %d size %zd-%zd ptr %016llx-%016llx\n", diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 3ca92b6b1172..979dc6a1957d 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -499,6 +499,12 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout_abort); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compact_finished); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wakeup_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_skip_swapcache); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_proc_transaction_finish); +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_free_buf); /* * For type visibility */ diff --git a/include/trace/hooks/binder.h b/include/trace/hooks/binder.h index fd877ec5b67f..c12926edc615 100644 --- a/include/trace/hooks/binder.h +++ b/include/trace/hooks/binder.h @@ -17,6 +17,8 @@ struct binder_proc; struct binder_thread; struct binder_transaction; struct binder_transaction_data; +struct binder_work; +struct binder_buffer; #else /* struct binder_alloc */ #include <../drivers/android/binder_alloc.h> @@ -114,6 +116,30 @@ DECLARE_HOOK(android_vh_binder_read_done, DECLARE_HOOK(android_vh_binder_has_work_ilocked, TP_PROTO(struct binder_thread *thread, bool do_proc_work, int *ret), TP_ARGS(thread, do_proc_work, ret)); +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_free_buf, + TP_PROTO(struct binder_proc *proc, struct binder_thread *thread, + struct binder_buffer *buffer), + TP_ARGS(proc, thread, buffer)); /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_BINDER_H */