ANDROID: binder: pass desired priority by reference
Avoid making unnecessary stack copies of struct binder_priority and pass the argument by reference instead. Rename 'desired_prio' to 'desired' to match the usage in other priority functions. There is no functional impact from this patch. Bug: 148101660 Signed-off-by: Carlos Llamas <cmllamas@google.com> Change-Id: I66ff5305296e7b9dba56ed265236f2af518f66e0 (cherry picked from commit 52d85f8a16467ce0bca374f885de24918f017371) [cmllamas: fixed minor merge conflict]
This commit is contained in:
parent
88c3fd6461
commit
807b6742c9
@ -651,19 +651,19 @@ static int to_kernel_prio(int policy, int user_priority)
|
||||
}
|
||||
|
||||
static void binder_do_set_priority(struct task_struct *task,
|
||||
struct binder_priority desired,
|
||||
const struct binder_priority *desired,
|
||||
bool verify)
|
||||
{
|
||||
int priority; /* user-space prio value */
|
||||
bool has_cap_nice;
|
||||
unsigned int policy = desired.sched_policy;
|
||||
unsigned int policy = desired->sched_policy;
|
||||
|
||||
if (task->policy == policy && task->normal_prio == desired.prio)
|
||||
if (task->policy == policy && task->normal_prio == desired->prio)
|
||||
return;
|
||||
|
||||
has_cap_nice = has_capability_noaudit(task, CAP_SYS_NICE);
|
||||
|
||||
priority = to_userspace_prio(policy, desired.prio);
|
||||
priority = to_userspace_prio(policy, desired->prio);
|
||||
|
||||
if (verify && is_rt_policy(policy) && !has_cap_nice) {
|
||||
long max_rtprio = task_rlimit(task, RLIMIT_RTPRIO);
|
||||
@ -688,16 +688,16 @@ static void binder_do_set_priority(struct task_struct *task,
|
||||
}
|
||||
}
|
||||
|
||||
if (policy != desired.sched_policy ||
|
||||
to_kernel_prio(policy, priority) != desired.prio)
|
||||
if (policy != desired->sched_policy ||
|
||||
to_kernel_prio(policy, priority) != desired->prio)
|
||||
binder_debug(BINDER_DEBUG_PRIORITY_CAP,
|
||||
"%d: priority %d not allowed, using %d instead\n",
|
||||
task->pid, desired.prio,
|
||||
task->pid, desired->prio,
|
||||
to_kernel_prio(policy, priority));
|
||||
|
||||
trace_binder_set_priority(task->tgid, task->pid, task->normal_prio,
|
||||
to_kernel_prio(policy, priority),
|
||||
desired.prio);
|
||||
desired->prio);
|
||||
|
||||
/* Set the actual priority */
|
||||
if (task->policy != policy || is_rt_policy(policy)) {
|
||||
@ -714,13 +714,13 @@ static void binder_do_set_priority(struct task_struct *task,
|
||||
}
|
||||
|
||||
static void binder_set_priority(struct task_struct *task,
|
||||
struct binder_priority desired)
|
||||
const struct binder_priority *desired)
|
||||
{
|
||||
binder_do_set_priority(task, desired, /* verify = */ true);
|
||||
}
|
||||
|
||||
static void binder_restore_priority(struct task_struct *task,
|
||||
struct binder_priority desired)
|
||||
const struct binder_priority *desired)
|
||||
{
|
||||
binder_do_set_priority(task, desired, /* verify = */ false);
|
||||
}
|
||||
@ -729,7 +729,7 @@ static void binder_transaction_priority(struct task_struct *task,
|
||||
struct binder_transaction *t,
|
||||
struct binder_node *node)
|
||||
{
|
||||
struct binder_priority desired_prio = t->priority;
|
||||
struct binder_priority desired = t->priority;
|
||||
const struct binder_priority node_prio = {
|
||||
.sched_policy = node->sched_policy,
|
||||
.prio = node->min_priority,
|
||||
@ -742,9 +742,9 @@ static void binder_transaction_priority(struct task_struct *task,
|
||||
t->saved_priority.sched_policy = task->policy;
|
||||
t->saved_priority.prio = task->normal_prio;
|
||||
|
||||
if (!node->inherit_rt && is_rt_policy(desired_prio.sched_policy)) {
|
||||
desired_prio.prio = NICE_TO_PRIO(0);
|
||||
desired_prio.sched_policy = SCHED_NORMAL;
|
||||
if (!node->inherit_rt && is_rt_policy(desired.sched_policy)) {
|
||||
desired.prio = NICE_TO_PRIO(0);
|
||||
desired.sched_policy = SCHED_NORMAL;
|
||||
}
|
||||
|
||||
if (node_prio.prio < t->priority.prio ||
|
||||
@ -757,10 +757,10 @@ static void binder_transaction_priority(struct task_struct *task,
|
||||
* SCHED_FIFO, prefer SCHED_FIFO, since it can
|
||||
* run unbounded, unlike SCHED_RR.
|
||||
*/
|
||||
desired_prio = node_prio;
|
||||
desired = node_prio;
|
||||
}
|
||||
|
||||
binder_set_priority(task, desired_prio);
|
||||
binder_set_priority(task, &desired);
|
||||
trace_android_vh_binder_set_priority(t, task);
|
||||
}
|
||||
|
||||
@ -3189,7 +3189,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(current, &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);
|
||||
@ -3303,7 +3303,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(current, &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);
|
||||
@ -3974,7 +3974,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(current, &proc->default_priority);
|
||||
}
|
||||
|
||||
if (non_block) {
|
||||
|
Loading…
Reference in New Issue
Block a user