mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 19:47:08 +02:00
sched/walt: guarantee result from energy efficient cpu
It is possible that walt_find_energy_efficient_cpu will return an error value, or a negative number for the cpu. In walt_lb_tick this was called without checking the return value. Update walt_find_energy_efficient_cpu to guarantee that it never returns a bad value, and that in all cases it returns prev_cpu if it cannot find an energy efficient cpu. Change-Id: Ifc08bdf42b8d54923f8a4ecc3ca8b2c0dba11f4f Signed-off-by: Stephen Dickey <quic_dickey@quicinc.com>
This commit is contained in:
parent
e8c7c38077
commit
53ef4e9eed
|
|
@ -1,6 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2020-2022, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <trace/hooks/sched.h>
|
||||
|
|
@ -788,7 +789,7 @@ int walt_find_energy_efficient_cpu(struct task_struct *p, int prev_cpu,
|
|||
return prev_cpu;
|
||||
|
||||
if (unlikely(!cpu_array))
|
||||
return -EPERM;
|
||||
return prev_cpu;
|
||||
|
||||
walt_get_indicies(p, &order_index, &end_index, task_boost, uclamp_boost,
|
||||
&energy_eval_needed);
|
||||
|
|
@ -926,6 +927,9 @@ int walt_find_energy_efficient_cpu(struct task_struct *p, int prev_cpu,
|
|||
rcu_read_unlock();
|
||||
|
||||
done:
|
||||
if (best_energy_cpu < 0 || best_energy_cpu >= WALT_NR_CPUS)
|
||||
best_energy_cpu = prev_cpu;
|
||||
|
||||
trace_sched_task_util(p, cpumask_bits(candidates)[0], best_energy_cpu,
|
||||
sync, fbt_env.need_idle, fbt_env.fastpath,
|
||||
start_t, uclamp_boost, start_cpu);
|
||||
|
|
@ -934,7 +938,7 @@ int walt_find_energy_efficient_cpu(struct task_struct *p, int prev_cpu,
|
|||
|
||||
fail:
|
||||
rcu_read_unlock();
|
||||
return -EPERM;
|
||||
return prev_cpu;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -952,8 +956,6 @@ walt_select_task_rq_fair(void *unused, struct task_struct *p, int prev_cpu,
|
|||
p->wake_q_count = 0;
|
||||
|
||||
*target_cpu = walt_find_energy_efficient_cpu(p, prev_cpu, sync, sibling_count_hint);
|
||||
if (unlikely(*target_cpu < 0))
|
||||
*target_cpu = prev_cpu;
|
||||
}
|
||||
|
||||
static void walt_binder_low_latency_set(void *unused, struct task_struct *task,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2020-2021, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2020-2022, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <trace/hooks/sched.h>
|
||||
|
|
@ -633,14 +633,10 @@ void walt_lb_tick(struct rq *rq)
|
|||
new_cpu = walt_find_energy_efficient_cpu(p, prev_cpu, 0, 1);
|
||||
rcu_read_unlock();
|
||||
|
||||
if (new_cpu < 0)
|
||||
goto out_unlock;
|
||||
|
||||
new_wrq = (struct walt_rq *) cpu_rq(new_cpu)->android_vendor_data1;
|
||||
|
||||
/* prevent active task migration to busy or same/lower capacity CPU */
|
||||
if (!available_idle_cpu(new_cpu) ||
|
||||
new_wrq->cluster->id <= prev_wrq->cluster->id)
|
||||
if (!available_idle_cpu(new_cpu) || new_wrq->cluster->id <= prev_wrq->cluster->id)
|
||||
goto out_unlock;
|
||||
|
||||
raw_spin_lock(&rq->__lock);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user