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 <cmllamas@google.com>
Change-Id: I67b599884580d957d776500e467827e5035c99f6
(cherry picked from commit 759d98484b5b51932d3d11651fa83c6bb268ce03)
This commit is contained in:
Carlos Llamas 2022-06-06 20:49:40 +00:00
parent 16c04a2732
commit e8fcc17a57
1 changed files with 14 additions and 12 deletions

View File

@ -648,10 +648,11 @@ static int to_kernel_prio(int policy, int user_priority)
return MAX_RT_PRIO - 1 - 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, const struct binder_priority *desired,
bool verify) bool verify)
{ {
struct task_struct *task = thread->task;
int priority; /* user-space prio value */ int priority; /* user-space prio value */
bool has_cap_nice; bool has_cap_nice;
unsigned int policy = desired->sched_policy; 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); 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) 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) 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_transaction *t,
struct binder_node *node) struct binder_node *node)
{ {
struct task_struct *task = thread->task;
struct binder_priority desired = t->priority; struct binder_priority desired = t->priority;
const struct binder_priority node_prio = { const struct binder_priority node_prio = {
.sched_policy = node->sched_policy, .sched_policy = node->sched_policy,
@ -758,7 +760,7 @@ static void binder_transaction_priority(struct task_struct *task,
desired = node_prio; desired = node_prio;
} }
binder_set_priority(task, &desired); binder_set_priority(thread, &desired);
trace_android_vh_binder_set_priority(t, task); trace_android_vh_binder_set_priority(t, task);
} }
@ -2535,7 +2537,7 @@ static int binder_proc_transaction(struct binder_transaction *t,
thread = binder_select_thread_ilocked(proc); thread = binder_select_thread_ilocked(proc);
if (thread) { if (thread) {
binder_transaction_priority(thread->task, t, node); binder_transaction_priority(thread, t, node);
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); binder_enqueue_work_ilocked(&t->work, &proc->todo);
@ -3243,7 +3245,7 @@ static void binder_transaction(struct binder_proc *proc,
binder_inner_proc_unlock(target_proc); binder_inner_proc_unlock(target_proc);
wake_up_interruptible_sync(&target_thread->wait); wake_up_interruptible_sync(&target_thread->wait);
trace_android_vh_binder_restore_priority(in_reply_to, current); 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); binder_free_transaction(in_reply_to);
} else if (!(t->flags & TF_ONE_WAY)) { } else if (!(t->flags & TF_ONE_WAY)) {
BUG_ON(t->buffer->async_transaction != 0); BUG_ON(t->buffer->async_transaction != 0);
@ -3359,7 +3361,7 @@ static void binder_transaction(struct binder_proc *proc,
BUG_ON(thread->return_error.cmd != BR_OK); BUG_ON(thread->return_error.cmd != BR_OK);
if (in_reply_to) { if (in_reply_to) {
trace_android_vh_binder_restore_priority(in_reply_to, current); 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; thread->return_error.cmd = BR_TRANSACTION_COMPLETE;
binder_enqueue_thread_work(thread, &thread->return_error.work); binder_enqueue_thread_work(thread, &thread->return_error.work);
binder_send_failed_reply(in_reply_to, return_error); binder_send_failed_reply(in_reply_to, return_error);
@ -4039,7 +4041,7 @@ static int binder_thread_read(struct binder_proc *proc,
binder_stop_on_user_error < 2); binder_stop_on_user_error < 2);
} }
trace_android_vh_binder_restore_priority(NULL, current); 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) { if (non_block) {
@ -4269,7 +4271,7 @@ static int binder_thread_read(struct binder_proc *proc,
trd->target.ptr = target_node->ptr; trd->target.ptr = target_node->ptr;
trd->cookie = target_node->cookie; trd->cookie = target_node->cookie;
binder_transaction_priority(current, t, target_node); binder_transaction_priority(thread, t, target_node);
cmd = BR_TRANSACTION; cmd = BR_TRANSACTION;
} else { } else {
trd->target.ptr = 0; trd->target.ptr = 0;