ANDROID: Add vendor hooks for binder perf tuning

Add vendor hook to get the binder message for vendor-specific power and
performance tuning.

Bug: 182496370
Bug: 235925535

Signed-off-by: Zhuguangqing <zhuguangqing@xiaomi.com>
Change-Id: Id47e59c4e3ccd07b26eef758ada147b98cd1964e
(cherry picked from commit 301e89472f3e00a2f02f1967d77efd051ada37f5)
Signed-off-by: heshuai1 <heshuai1@xiaomi.com>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
[ cmllamas: don't export complete private definition struct binder_alloc
  in vendor hooks, instead just pass member alloc->free_async_space as
  implemented by heshuai1 and squashed here ]
This commit is contained in:
Zhuguangqing 2021-03-09 15:47:43 +08:00 committed by Carlos Llamas
parent d559034f20
commit 254fb1f403
4 changed files with 19 additions and 1 deletions

View File

@ -2822,6 +2822,7 @@ static void binder_transaction(struct binder_proc *proc,
target_proc = target_thread->proc;
target_proc->tmp_ref++;
binder_inner_proc_unlock(target_thread->proc);
trace_android_vh_binder_reply(target_proc, proc, thread, tr);
} else {
if (tr->target.handle) {
struct binder_ref *ref;
@ -2880,6 +2881,7 @@ static void binder_transaction(struct binder_proc *proc,
return_error_line = __LINE__;
goto err_invalid_target_handle;
}
trace_android_vh_binder_trans(target_proc, proc, thread, tr);
if (security_binder_transaction(proc->cred,
target_proc->cred) < 0) {
return_error = BR_FAILED_REPLY;

View File

@ -25,6 +25,7 @@
#include <linux/sizes.h>
#include "binder_alloc.h"
#include "binder_trace.h"
#include <trace/hooks/binder.h>
struct list_lru binder_alloc_lru;
@ -421,6 +422,7 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
alloc->pid, extra_buffers_size);
return ERR_PTR(-EINVAL);
}
trace_android_vh_binder_alloc_new_buf_locked(size, &alloc->free_async_space, is_async);
if (is_async &&
alloc->free_async_space < size + sizeof(struct binder_buffer)) {
binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,

View File

@ -401,6 +401,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_free_proc);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_thread_release);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_has_work_ilocked);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_read_done);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_preset);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_v2_resume);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_signal);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_alloc_new_buf_locked);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_reply);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_trans);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_preset);

View File

@ -77,6 +77,17 @@ DECLARE_HOOK(android_vh_binder_read_done,
DECLARE_HOOK(android_vh_binder_has_work_ilocked,
TP_PROTO(struct binder_thread *thread, bool do_proc_work, int *ret),
TP_ARGS(thread, do_proc_work, ret));
DECLARE_HOOK(android_vh_binder_alloc_new_buf_locked,
TP_PROTO(size_t size, size_t *free_async_space, int is_async),
TP_ARGS(size, free_async_space, is_async));
DECLARE_HOOK(android_vh_binder_reply,
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));
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));
DECLARE_HOOK(android_vh_binder_preset,
TP_PROTO(struct hlist_head *hhead, struct mutex *lock),
TP_ARGS(hhead, lock));