ANDROID: vendor_hooks: Add hooks to implement the feature of improving the scheduling priority of binder_sched->task
1) Check if it is a specific task in trace_android_vh_alloc_oem_binder_struct() and store the flag to t->android_vendor_data1 2) If it is a specific binder task and binder_thread selected, raise the scheduling priority of binder_thread->task in trace_android_vh_binder_proc_transaction_finish(). 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 in trace_android_vh_binder_special_task(). 4) Some states are cleared in trace_android_vh_binder_transaction_received(). On the other hand, if no thread is selected in binder_proc_transaction() for async binders, the scheduling priority will be boosted here. 5) Restore the scheduling priority when BC_FREE_BUFFER in trace_android_vh_binder_buffer_release(). Bug: 329740751 Bug: 325855598 Change-Id: Iab4939fe4a4881b31961aaa2fef500b51c944743 Signed-off-by: Fuchun Liao <lfc@oppo.com> Signed-off-by: Liujie Xie <xieliujie@oppo.com>
This commit is contained in:
committed by
Treehugger Robot
parent
937bd07184
commit
e80ae43256
@@ -1834,6 +1834,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--;
|
||||
@@ -3023,6 +3024,7 @@ static int binder_proc_transaction(struct binder_transaction *t,
|
||||
bool pending_async = false;
|
||||
struct binder_transaction *t_outdated = NULL;
|
||||
bool frozen = false;
|
||||
bool enqueue_task = true;
|
||||
|
||||
BUG_ON(!node);
|
||||
binder_node_lock(node);
|
||||
@@ -3056,7 +3058,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) && frozen) {
|
||||
t_outdated = binder_find_outdated_transaction_ilocked(t,
|
||||
@@ -3069,9 +3074,14 @@ 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,
|
||||
thread ? thread->task : NULL, pending_async, !oneway);
|
||||
if (!pending_async)
|
||||
binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */);
|
||||
|
||||
@@ -3545,6 +3555,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,
|
||||
@@ -4206,10 +4217,14 @@ binder_free_buf(struct binder_proc *proc,
|
||||
struct binder_thread *thread,
|
||||
struct binder_buffer *buffer, bool is_failure)
|
||||
{
|
||||
bool enqueue_task = true;
|
||||
bool has_transaction = false;
|
||||
|
||||
binder_inner_proc_lock(proc);
|
||||
if (buffer->transaction) {
|
||||
buffer->transaction->buffer = NULL;
|
||||
buffer->transaction = NULL;
|
||||
has_transaction = true;
|
||||
}
|
||||
binder_inner_proc_unlock(proc);
|
||||
if (buffer->async_transaction && buffer->target_node) {
|
||||
@@ -4225,12 +4240,16 @@ 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);
|
||||
}
|
||||
trace_android_vh_binder_buffer_release(proc, thread, buffer,
|
||||
has_transaction);
|
||||
trace_binder_transaction_buffer_release(buffer);
|
||||
binder_release_entire_buffer(proc, thread, buffer, is_failure);
|
||||
binder_alloc_free_buf(&proc->alloc, buffer);
|
||||
@@ -5243,6 +5262,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 %u size %zd-%zd ptr %016llx-%016llx\n",
|
||||
|
||||
@@ -91,6 +91,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_allow_domain_state);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpuidle_psci_enter);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpuidle_psci_exit);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpufreq_transition);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_proc_transaction_finish);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sync_txn_recvd);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_balance_anon_file_reclaim);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_show_max_freq);
|
||||
@@ -122,6 +123,11 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_bypass);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_isolate_freepages);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_check_panic);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_wait_for_work);
|
||||
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_buffer_release);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_folio_look_around_ref);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_look_around);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_look_around_migrate_folio);
|
||||
|
||||
@@ -14,6 +14,9 @@ struct binder_transaction;
|
||||
struct task_struct;
|
||||
struct binder_thread;
|
||||
struct binder_proc;
|
||||
struct binder_work;
|
||||
struct binder_buffer;
|
||||
struct binder_transaction_data;
|
||||
DECLARE_HOOK(android_vh_binder_transaction_init,
|
||||
TP_PROTO(struct binder_transaction *t),
|
||||
TP_ARGS(t));
|
||||
@@ -29,6 +32,30 @@ DECLARE_HOOK(android_vh_binder_wait_for_work,
|
||||
DECLARE_HOOK(android_vh_sync_txn_recvd,
|
||||
TP_PROTO(struct task_struct *tsk, struct task_struct *from),
|
||||
TP_ARGS(tsk, from));
|
||||
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_buffer_release,
|
||||
TP_PROTO(struct binder_proc *proc, struct binder_thread *thread,
|
||||
struct binder_buffer *buffer, bool has_transaction),
|
||||
TP_ARGS(proc, thread, buffer, has_transaction));
|
||||
#endif /* _TRACE_HOOK_BINDER_H */
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
||||
|
||||
Reference in New Issue
Block a user