From 759d98484b5b51932d3d11651fa83c6bb268ce03 Mon Sep 17 00:00:00 2001 From: Carlos Llamas Date: Mon, 6 Jun 2022 20:49:40 +0000 Subject: [PATCH] ANDROID: binder: switch task argument for binder_thread Refactor binder priority functions to take in 'struct binder_thread *' instead of just 'struct task_struct *'. This allows access to other thread fields used in subsequent patches. In any case, the same task reference is still available under thread->task. There is no functional impact from this patch. Bug: 148101660 Signed-off-by: Carlos Llamas Change-Id: I67b599884580d957d776500e467827e5035c99f6 --- drivers/android/binder.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 5fd3b653b6c1..cfb13996fe0d 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -648,10 +648,11 @@ static int to_kernel_prio(int policy, int user_priority) return MAX_RT_PRIO - 1 - user_priority; } -static void binder_do_set_priority(struct task_struct *task, +static void binder_do_set_priority(struct binder_thread *thread, const struct binder_priority *desired, bool verify) { + struct task_struct *task = thread->task; int priority; /* user-space prio value */ bool has_cap_nice; unsigned int policy = desired->sched_policy; @@ -711,22 +712,23 @@ static void binder_do_set_priority(struct task_struct *task, set_user_nice(task, priority); } -static void binder_set_priority(struct task_struct *task, +static void binder_set_priority(struct binder_thread *thread, const struct binder_priority *desired) { - binder_do_set_priority(task, desired, /* verify = */ true); + binder_do_set_priority(thread, desired, /* verify = */ true); } -static void binder_restore_priority(struct task_struct *task, +static void binder_restore_priority(struct binder_thread *thread, const struct binder_priority *desired) { - binder_do_set_priority(task, desired, /* verify = */ false); + binder_do_set_priority(thread, desired, /* verify = */ false); } -static void binder_transaction_priority(struct task_struct *task, +static void binder_transaction_priority(struct binder_thread *thread, struct binder_transaction *t, struct binder_node *node) { + struct task_struct *task = thread->task; struct binder_priority desired = t->priority; const struct binder_priority node_prio = { .sched_policy = node->sched_policy, @@ -758,7 +760,7 @@ static void binder_transaction_priority(struct task_struct *task, desired = node_prio; } - binder_set_priority(task, &desired); + binder_set_priority(thread, &desired); trace_android_vh_binder_set_priority(t, task); } @@ -2785,7 +2787,7 @@ static int binder_proc_transaction(struct binder_transaction *t, thread = binder_select_thread_ilocked(proc); if (thread) { - binder_transaction_priority(thread->task, t, node); + 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); @@ -3525,7 +3527,7 @@ static void binder_transaction(struct binder_proc *proc, binder_inner_proc_unlock(target_proc); wake_up_interruptible_sync(&target_thread->wait); trace_android_vh_binder_restore_priority(in_reply_to, current); - binder_restore_priority(current, &in_reply_to->saved_priority); + binder_restore_priority(thread, &in_reply_to->saved_priority); binder_free_transaction(in_reply_to); } else if (!(t->flags & TF_ONE_WAY)) { BUG_ON(t->buffer->async_transaction != 0); @@ -3642,7 +3644,7 @@ err_invalid_target_handle: BUG_ON(thread->return_error.cmd != BR_OK); if (in_reply_to) { trace_android_vh_binder_restore_priority(in_reply_to, current); - binder_restore_priority(current, &in_reply_to->saved_priority); + binder_restore_priority(thread, &in_reply_to->saved_priority); thread->return_error.cmd = BR_TRANSACTION_COMPLETE; binder_enqueue_thread_work(thread, &thread->return_error.work); binder_send_failed_reply(in_reply_to, return_error); @@ -4322,7 +4324,7 @@ retry: binder_stop_on_user_error < 2); } trace_android_vh_binder_restore_priority(NULL, current); - binder_restore_priority(current, &proc->default_priority); + binder_restore_priority(thread, &proc->default_priority); } if (non_block) { @@ -4552,7 +4554,7 @@ retry: trd->target.ptr = target_node->ptr; trd->cookie = target_node->cookie; - binder_transaction_priority(current, t, target_node); + binder_transaction_priority(thread, t, target_node); cmd = BR_TRANSACTION; } else { trd->target.ptr = 0;