From 5d6c9601a086df348ae5f8c41196e11d84e08b29 Mon Sep 17 00:00:00 2001 From: Stephen Dickey Date: Wed, 19 Jan 2022 11:31:11 -0800 Subject: [PATCH] sched/walt: update select_task_rq_rt to filter halted cpus walt_rt_energy_aware_wake_cpu could return -1, which makes walt_select_task_rq_rt use the task's prev cpu (the backup cpu). However, the backup_cpu could be halted. Address this by replacing the chosen cpu with the lowest order non-halted cpu in the system. Change-Id: I366bd2e9093b945a093ae4542a77983b0bc57229 Signed-off-by: Stephen Dickey --- kernel/sched/walt/walt_rt.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kernel/sched/walt/walt_rt.c b/kernel/sched/walt/walt_rt.c index ec299ce106ef..594990a18291 100644 --- a/kernel/sched/walt/walt_rt.c +++ b/kernel/sched/walt/walt_rt.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2020-2022, The Linux Foundation. All rights reserved. */ #include @@ -217,6 +217,17 @@ static void walt_select_task_rq_rt(void *unused, struct task_struct *task, int c (may_not_preempt || task->prio < cpu_rq(target)->rt.highest_prio.curr)) *new_cpu = target; + /* if backup or chosen cpu is halted, pick something else */ + if (cpu_halted(*new_cpu)) { + cpumask_t non_halted; + + /* choose the lowest-order, unhalted, allowed CPU */ + cpumask_andnot(&non_halted, task->cpus_ptr, cpu_halt_mask); + target = cpumask_first(&non_halted); + if (target < nr_cpu_ids) + *new_cpu = target; + } + rcu_read_unlock(); }