ANDROID: vendor_hooks: add hook to record binder transaction info

Add vendor hook to record binder transaction information and
support oem's print binder transaction info.

Our function is to help locate whether the problem is caused by binder
blocking when ANR or watchdog occurs;So we need to add timestamps,
synchronous or asynchronous process information to the binder_procs
node, and create our own file node to readbinder_procs,
binder_transaction_log and binder_transaction_log_failed,
and output them in the format we need.

On kernel 6.6, we implement this with an OGKI patch, now we want
to achieve this by adding this vendor hook (also helps to reduce
our OGKI patches).This is a custom function, which will affect
performance. I turn this unction on or off according to different
products. It is not available for all OEMs, so it is not available
upstream.

Bug: 409484697
Change-Id: I36109e9045e284cc8be8dbffb79fc5b509a67c06
Signed-off-by: zhengwei <zhengwei2@honor.com>
This commit is contained in:
zhengwei
2025-04-11 14:30:19 +08:00
committed by Treehugger Robot
parent f5cc702b4f
commit b13ee5ea88
4 changed files with 29 additions and 1 deletions
+5
View File
@@ -3900,6 +3900,8 @@ static void binder_transaction(struct binder_proc *proc,
tcomplete->type = BINDER_WORK_TRANSACTION_COMPLETE;
t->work.type = BINDER_WORK_TRANSACTION;
trace_android_vh_binder_transaction_record(tr, t, in_reply_to);
if (reply) {
binder_enqueue_thread_work(thread, tcomplete);
binder_inner_proc_lock(target_proc);
@@ -6298,6 +6300,9 @@ static int binder_open(struct inode *nodp, struct file *filp)
filp->private_data = proc;
trace_android_vh_binder_preset(&binder_procs, &binder_procs_lock, proc);
trace_android_vh_binder_data_preset(&binder_procs, &binder_procs_lock,
&binder_transaction_log, &binder_transaction_log_failed,
sizeof(struct binder_transaction_log));
mutex_lock(&binder_procs_lock);
hlist_for_each_entry(itr, &binder_procs, proc_node) {
if (itr->pid == proc->pid) {
+2 -1
View File
@@ -31,7 +31,7 @@
#include <linux/xarray.h>
#include <uapi/linux/android/binder.h>
#include <uapi/linux/android/binderfs.h>
#include <trace/hooks/binder.h>
#include "binder_internal.h"
#define FIRST_INODE 1
@@ -649,6 +649,7 @@ static int init_binder_logs(struct super_block *sb)
ret = PTR_ERR(proc_log_dir);
goto out;
}
trace_android_rvh_init_binder_logs(sb);
info = sb->s_fs_info;
info->proc_log_dir = proc_log_dir;
+3
View File
@@ -425,6 +425,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_reply);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_trans);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_proc_transaction);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_thread_read);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_init_binder_logs);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_data_preset);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_transaction_record);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_inode_io_list_del);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_redirty_tail_locked);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_queue_io);
+19
View File
@@ -17,6 +17,8 @@ struct binder_proc;
struct binder_work;
struct binder_buffer;
struct binder_transaction_data;
struct binder_transaction_log;
DECLARE_HOOK(android_vh_binder_transaction_init,
TP_PROTO(struct binder_transaction *t),
TP_ARGS(t));
@@ -112,6 +114,23 @@ DECLARE_HOOK(android_vh_binder_thread_read,
TP_PROTO(struct list_head **list, struct binder_proc *proc,
struct binder_thread *thread),
TP_ARGS(list, proc, thread));
DECLARE_HOOK(android_vh_binder_transaction_record,
TP_PROTO(struct binder_transaction_data *tr,
struct binder_transaction *t,
struct binder_transaction *in_reply_to),
TP_ARGS(tr, t, in_reply_to));
DECLARE_HOOK(android_vh_binder_data_preset,
TP_PROTO(struct hlist_head *binder_procs,
struct mutex *binder_procs_lock,
struct binder_transaction_log *binder_transaction_log,
struct binder_transaction_log *binder_transaction_log_failed,
size_t size),
TP_ARGS(binder_procs,
binder_procs_lock, binder_transaction_log,
binder_transaction_log_failed, size));
DECLARE_RESTRICTED_HOOK(android_rvh_init_binder_logs,
TP_PROTO(struct super_block *sb),
TP_ARGS(sb), 1);
DECLARE_HOOK(android_vh_binder_new_ref,
TP_PROTO(struct binder_proc *proc, uint32_t ref_desc, int node_debug_id),
TP_ARGS(proc, ref_desc, node_debug_id));