diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 4f89346dd283..8b7448753183 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -1761,6 +1761,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--; @@ -2945,6 +2946,7 @@ static int binder_proc_transaction(struct binder_transaction *t, bool pending_async = false; struct binder_transaction *t_outdated = NULL; bool skip = false; + bool enqueue_task = true; BUG_ON(!node); binder_node_lock(node); @@ -2984,7 +2986,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) && proc->is_frozen) { t_outdated = binder_find_outdated_transaction_ilocked(t, @@ -2997,7 +3002,10 @@ 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, @@ -3474,6 +3482,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, @@ -3978,6 +3987,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; @@ -3997,8 +4009,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); @@ -4940,6 +4954,7 @@ skip: 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 104e4eb48ff9..a1bbaf5a33d1 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -329,3 +329,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_check); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_freeze_whether_wake); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_use_amu_fie); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_scan_abort_check_wmarks); +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); diff --git a/include/trace/hooks/binder.h b/include/trace/hooks/binder.h index 991e9b1271a1..216b5645db73 100644 --- a/include/trace/hooks/binder.h +++ b/include/trace/hooks/binder.h @@ -11,7 +11,11 @@ * mechanism for vendor modules to hook and extend functionality */ struct binder_transaction; +struct binder_transaction_data; struct task_struct; +struct binder_work; +struct binder_buffer; + DECLARE_HOOK(android_vh_binder_transaction_init, TP_PROTO(struct binder_transaction *t), TP_ARGS(t)); @@ -93,6 +97,26 @@ DECLARE_HOOK(android_vh_binder_new_ref, DECLARE_HOOK(android_vh_binder_del_ref, TP_PROTO(struct task_struct *proc, uint32_t ref_desc), TP_ARGS(proc, ref_desc)); +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)); #endif /* _TRACE_HOOK_BINDER_H */ /* This part must be outside protection */