ANDROID: binder: Add vendor hooks to implement the feature of

binder_proc->fg_todo list

1. The implementation logic of this feature
1) In trace_android_vh_binder_list_add_work, record the sequence of work, work->android_oem_data1 = atomic64_inc_return(&binder_work_seq).
2) In the binder_proc_transaction() function, for special synchronized
binders, if a thread is not found, t->work will be added to proc->fg_todo in trace_android_vh_binder_special_task().
3) binder_thread_read() -> trace_android_vh_binder_select_special_worklist()
will select work to execute from proc->fg_todo according to a specific
algorithm, such as selecting the thread->todo first, then selecting two
proc->fg_todo works, and then one proc->todo work, while taking into account the sequence of work (work->android_oem_data1).
proc->ANDROID_OEM_DATA(1) is used to generate proc->fg_todo list, and it
was committed in the id 8a3740893d9957783493364b118282daa71695cc by other colleagues.

2. trace_android_vh_binder_list_add_work: record the sequence of work.

3. trace_android_vh_binder_has_proc_work_ilocked: Check if there is work
in proc->fg_todo list, and if so, then binder_wakeup_proc_ilocked.

4. trace_android_vh_binder_check_special_work: release the work on
proc->fg_todo list, and print the binder work on fg_list.

Bug: 334746237
Bug: 395737475

Change-Id: I855618ee129fe1bb5925b169d24eb2301ad90664
Signed-off-by: Fuchun Liao <lfc@oppo.com>
This commit is contained in:
Fuchun Liao
2024-04-23 14:57:42 +08:00
committed by Treehugger Robot
parent 0ebf9a330d
commit f831b886d2
4 changed files with 40 additions and 5 deletions
+14 -3
View File
@@ -58,9 +58,21 @@ DECLARE_HOOK(android_vh_binder_buffer_release,
TP_ARGS(proc, thread, buffer, has_transaction));
struct binder_proc;
struct binder_thread;
DECLARE_HOOK(android_vh_binder_list_add_work,
TP_PROTO(struct binder_work *work, struct list_head *target_list),
TP_ARGS(work, target_list));
DECLARE_HOOK(android_vh_binder_has_proc_work_ilocked,
TP_PROTO(struct binder_thread *thread, bool do_proc_work, bool *has_work),
TP_ARGS(thread, do_proc_work, has_work));
DECLARE_HOOK(android_vh_binder_check_special_work,
TP_PROTO(struct binder_proc *proc, struct list_head **special_list),
TP_ARGS(proc, special_list));
DECLARE_HOOK(android_vh_binder_free_proc,
TP_PROTO(struct binder_proc *proc),
TP_ARGS(proc));
DECLARE_HOOK(android_vh_binder_preset,
TP_PROTO(struct hlist_head *hhead, struct mutex *lock),
TP_ARGS(hhead, lock));
TP_PROTO(struct hlist_head *hhead, struct mutex *lock, struct binder_proc *proc),
TP_ARGS(hhead, lock, proc));
struct binder_transaction_data;
DECLARE_HOOK(android_vh_binder_reply,
TP_PROTO(struct binder_proc *target_proc, struct binder_proc *proc,
@@ -70,7 +82,6 @@ DECLARE_HOOK(android_vh_binder_trans,
TP_PROTO(struct binder_proc *target_proc, struct binder_proc *proc,
struct binder_thread *thread, struct binder_transaction_data *tr),
TP_ARGS(target_proc, proc, thread, tr));
#endif /* _TRACE_HOOK_BINDER_H */
/* This part must be outside protection */
#include <trace/define_trace.h>