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_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 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: 308391339 Change-Id: Iab4939fe4a4881b31961aaa2fef500b51c944743 Signed-off-by: lfc <lfc@oppo.com>
This commit is contained in:
@@ -1673,6 +1673,7 @@ static void binder_free_transaction(struct binder_transaction *t)
|
|||||||
{
|
{
|
||||||
struct binder_proc *target_proc = t->to_proc;
|
struct binder_proc *target_proc = t->to_proc;
|
||||||
|
|
||||||
|
trace_android_vh_free_oem_binder_struct(t);
|
||||||
if (target_proc) {
|
if (target_proc) {
|
||||||
binder_inner_proc_lock(target_proc);
|
binder_inner_proc_lock(target_proc);
|
||||||
target_proc->outstanding_txns--;
|
target_proc->outstanding_txns--;
|
||||||
@@ -2855,6 +2856,7 @@ static int binder_proc_transaction(struct binder_transaction *t,
|
|||||||
bool oneway = !!(t->flags & TF_ONE_WAY);
|
bool oneway = !!(t->flags & TF_ONE_WAY);
|
||||||
bool pending_async = false;
|
bool pending_async = false;
|
||||||
struct binder_transaction *t_outdated = NULL;
|
struct binder_transaction *t_outdated = NULL;
|
||||||
|
bool enqueue_task = true;
|
||||||
|
|
||||||
BUG_ON(!node);
|
BUG_ON(!node);
|
||||||
binder_node_lock(node);
|
binder_node_lock(node);
|
||||||
@@ -2894,7 +2896,10 @@ static int binder_proc_transaction(struct binder_transaction *t,
|
|||||||
node->inherit_rt);
|
node->inherit_rt);
|
||||||
binder_enqueue_thread_work_ilocked(thread, &t->work);
|
binder_enqueue_thread_work_ilocked(thread, &t->work);
|
||||||
} else if (!pending_async) {
|
} 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 {
|
} else {
|
||||||
if ((t->flags & TF_UPDATE_TXN) && proc->is_frozen) {
|
if ((t->flags & TF_UPDATE_TXN) && proc->is_frozen) {
|
||||||
t_outdated = binder_find_outdated_transaction_ilocked(t,
|
t_outdated = binder_find_outdated_transaction_ilocked(t,
|
||||||
@@ -2907,11 +2912,16 @@ static int binder_proc_transaction(struct binder_transaction *t,
|
|||||||
proc->outstanding_txns--;
|
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_end(current, proc->tsk,
|
trace_android_vh_binder_proc_transaction_end(current, proc->tsk,
|
||||||
thread ? thread->task : NULL, t->code, pending_async, !oneway);
|
thread ? thread->task : NULL, t->code, pending_async, !oneway);
|
||||||
|
trace_android_vh_binder_proc_transaction_finish(proc, t,
|
||||||
|
thread ? thread->task : NULL, pending_async, !oneway);
|
||||||
|
|
||||||
if (!pending_async)
|
if (!pending_async)
|
||||||
binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */);
|
binder_wakeup_thread_ilocked(proc, thread, !oneway /* sync */);
|
||||||
@@ -3349,6 +3359,7 @@ static void binder_transaction(struct binder_proc *proc,
|
|||||||
t->buffer->target_node = target_node;
|
t->buffer->target_node = target_node;
|
||||||
t->buffer->clear_on_free = !!(t->flags & TF_CLEAR_BUF);
|
t->buffer->clear_on_free = !!(t->flags & TF_CLEAR_BUF);
|
||||||
trace_binder_transaction_alloc_buf(t->buffer);
|
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(
|
if (binder_alloc_copy_user_to_buffer(
|
||||||
&target_proc->alloc,
|
&target_proc->alloc,
|
||||||
@@ -3818,6 +3829,9 @@ binder_free_buf(struct binder_proc *proc,
|
|||||||
struct binder_thread *thread,
|
struct binder_thread *thread,
|
||||||
struct binder_buffer *buffer, bool is_failure)
|
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);
|
binder_inner_proc_lock(proc);
|
||||||
if (buffer->transaction) {
|
if (buffer->transaction) {
|
||||||
buffer->transaction->buffer = NULL;
|
buffer->transaction->buffer = NULL;
|
||||||
@@ -3837,8 +3851,10 @@ binder_free_buf(struct binder_proc *proc,
|
|||||||
if (!w) {
|
if (!w) {
|
||||||
buf_node->has_async_transaction = false;
|
buf_node->has_async_transaction = false;
|
||||||
} else {
|
} else {
|
||||||
binder_enqueue_work_ilocked(
|
trace_android_vh_binder_special_task(NULL, proc, thread, w,
|
||||||
w, &proc->todo);
|
&proc->todo, false, &enqueue_task);
|
||||||
|
if (enqueue_task)
|
||||||
|
binder_enqueue_work_ilocked(w, &proc->todo);
|
||||||
binder_wakeup_proc_ilocked(proc);
|
binder_wakeup_proc_ilocked(proc);
|
||||||
}
|
}
|
||||||
binder_node_inner_unlock(buf_node);
|
binder_node_inner_unlock(buf_node);
|
||||||
@@ -4785,6 +4801,7 @@ retry:
|
|||||||
ptr += trsize;
|
ptr += trsize;
|
||||||
|
|
||||||
trace_binder_transaction_received(t);
|
trace_binder_transaction_received(t);
|
||||||
|
trace_android_vh_binder_transaction_received(t, proc, thread, cmd);
|
||||||
binder_stat_br(proc, thread, cmd);
|
binder_stat_br(proc, thread, cmd);
|
||||||
binder_debug(BINDER_DEBUG_TRANSACTION,
|
binder_debug(BINDER_DEBUG_TRANSACTION,
|
||||||
"%d:%d %s %d %d:%d, cmd %d size %zd-%zd ptr %016llx-%016llx\n",
|
"%d:%d %s %d %d:%d, cmd %d size %zd-%zd ptr %016llx-%016llx\n",
|
||||||
|
@@ -499,6 +499,12 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_cold_or_pageout_abort);
|
|||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compact_finished);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_compact_finished);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wakeup_bypass);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wakeup_bypass);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_skip_swapcache);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_skip_swapcache);
|
||||||
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_proc_transaction_finish);
|
||||||
|
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);
|
||||||
/*
|
/*
|
||||||
* For type visibility
|
* For type visibility
|
||||||
*/
|
*/
|
||||||
|
@@ -17,6 +17,8 @@ struct binder_proc;
|
|||||||
struct binder_thread;
|
struct binder_thread;
|
||||||
struct binder_transaction;
|
struct binder_transaction;
|
||||||
struct binder_transaction_data;
|
struct binder_transaction_data;
|
||||||
|
struct binder_work;
|
||||||
|
struct binder_buffer;
|
||||||
#else
|
#else
|
||||||
/* struct binder_alloc */
|
/* struct binder_alloc */
|
||||||
#include <../drivers/android/binder_alloc.h>
|
#include <../drivers/android/binder_alloc.h>
|
||||||
@@ -114,6 +116,30 @@ DECLARE_HOOK(android_vh_binder_read_done,
|
|||||||
DECLARE_HOOK(android_vh_binder_has_work_ilocked,
|
DECLARE_HOOK(android_vh_binder_has_work_ilocked,
|
||||||
TP_PROTO(struct binder_thread *thread, bool do_proc_work, int *ret),
|
TP_PROTO(struct binder_thread *thread, bool do_proc_work, int *ret),
|
||||||
TP_ARGS(thread, do_proc_work, ret));
|
TP_ARGS(thread, do_proc_work, ret));
|
||||||
|
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_free_buf,
|
||||||
|
TP_PROTO(struct binder_proc *proc, struct binder_thread *thread,
|
||||||
|
struct binder_buffer *buffer),
|
||||||
|
TP_ARGS(proc, thread, buffer));
|
||||||
/* macro versions of hooks are no longer required */
|
/* macro versions of hooks are no longer required */
|
||||||
|
|
||||||
#endif /* _TRACE_HOOK_BINDER_H */
|
#endif /* _TRACE_HOOK_BINDER_H */
|
||||||
|
Reference in New Issue
Block a user