ANDROID: vendor_hooks: Add hooks for binder
Add hooks to support oem's binder feature of improving binder_thread->task sched priority 1) Check if it is a specific task in trace_android_vh_binder_transaction_buffer() and store the flag to t->android_vendor_data1 2) If it is a specific binder task and binder_thread selected, raise the sched priority of binder_thread->task in runqueue. 3) If it is a specific binder task but no binder_thread selected (e.g pending_async or no free threads), insert t->work to the appropriate position in the list. 4) Reset the sched priority when BR_TRANSACTION or BC_FREE_BUFFER. Some high-priority async binder task reset the sched priority when BC_FREE_BUFFER in trace_android_vh_binder_free_buf(). Some middle-priority async binder task reset the sched priority when driver return server "BR_TRANSACTION" in trace_android_vh_binder_transaction_received(). Bug: 299328919 Change-Id: Iab4939fe4a4881b31961aaa2fef500b51c944743 Signed-off-by: lfc <lfc@oppo.com>
This commit is contained in:
parent
c6724bfeda
commit
740a51391b
@ -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 @@ static int binder_thread_read(struct binder_proc *proc,
|
||||
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",
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user