From 26265ecbab9a46665859cd49cfd06fa2a3316598 Mon Sep 17 00:00:00 2001 From: Chungkai Mei Date: Sun, 9 Apr 2023 14:37:21 +0000 Subject: [PATCH] ANDROID: binder: set default min and max uclamp to 0 and SCHED_CAPACITY_SCALE Don't use the uclamp of current task as the default uclamp for binders, because the uclamp of current task influence binders' placement when not in a transaction. Just use default value 0 and SCHED_CAPACITY_SCALE for binders' default uclamp min and max. Also replace set_inherited_uclamp with set_binder_prio_uclamp Bug: 277389699 Change-Id: I07c4f40c2689dbc7eb23e7d3e2a2f435353dc25f Signed-off-by: Chungkai Mei --- drivers/android/binder.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index a0f821e71f68..9316ec2cb868 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -664,17 +664,13 @@ static void set_binder_prio_uclamp(struct binder_priority *prio, struct task_str if (!uclamp_is_used()) return; - prio->uclamp[UCLAMP_MIN] = task->uclamp_req[UCLAMP_MIN].value; - prio->uclamp[UCLAMP_MAX] = task->uclamp_req[UCLAMP_MAX].value; -} - -static void set_inherited_uclamp(struct binder_transaction *t) -{ - if (!uclamp_is_used()) - return; - - t->priority.uclamp[UCLAMP_MIN] = uclamp_eff_value(current, UCLAMP_MIN); - t->priority.uclamp[UCLAMP_MAX] = uclamp_eff_value(current, UCLAMP_MAX); + if (task) { + prio->uclamp[UCLAMP_MIN] = uclamp_eff_value(task, UCLAMP_MIN); + prio->uclamp[UCLAMP_MAX] = uclamp_eff_value(task, UCLAMP_MAX); + } else { + prio->uclamp[UCLAMP_MIN] = 0; + prio->uclamp[UCLAMP_MAX] = SCHED_CAPACITY_SCALE; + } } static bool is_uclamp_equal(struct task_struct *task, const struct binder_priority *desired) @@ -688,7 +684,6 @@ static bool is_uclamp_equal(struct task_struct *task, const struct binder_priori #else static void set_binder_prio_uclamp(struct binder_priority *prio, struct task_struct *task) { } -static void set_inherited_uclamp(struct binder_transaction *t) { } static bool is_uclamp_equal(struct task_struct *task, const struct binder_priority *desired) { return true; @@ -3360,7 +3355,7 @@ static void binder_transaction(struct binder_proc *proc, } if (!(t->flags & TF_ONE_WAY)) - set_inherited_uclamp(t); + set_binder_prio_uclamp(&t->priority, current); if (target_node && target_node->txn_security_ctx) { u32 secid; @@ -5782,7 +5777,7 @@ static int binder_open(struct inode *nodp, struct file *filp) proc->default_priority.prio = NICE_TO_PRIO(0); } - set_binder_prio_uclamp(&proc->default_priority, current); + set_binder_prio_uclamp(&proc->default_priority, NULL); /* binderfs stashes devices in i_private */ if (is_binderfs_device(nodp)) {