sched/walt: Prevent cpu rejection if only unhalted cpus are online

In certain chipsets, there will be no constraint on which cpus are
allowed to be offlined. In an extreme case where the last online
cpu is a halted cpu, the requested cpu will still be rejected.
This causes an unacceptable case to the upstream fallback cpu
selection, and the system will crash.

Avoid this by ensuring that if there are no online unhalted cpus
the requested cpu will always be allowed.

Change-Id: I7bf59bf5490a024fb1a28fc60f4acc38285d05e2
Signed-off-by: Stephen Dickey <quic_dickey@quicinc.com>
This commit is contained in:
Stephen Dickey 2023-01-11 12:14:21 -08:00
parent b7904fdca4
commit 92edb0ce6a

View File

@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2021-2021 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/cpu.h>
#include <linux/cpumask.h>
@ -562,6 +561,20 @@ static void android_rvh_is_cpu_allowed(void *unused, struct task_struct *p, int
* the context is execve. allow this cpu.
*/
*allowed = true;
} else {
cpumask_t active_unhalted_cpus;
/* make sure there is a cpu to handle this task */
cpumask_andnot(&active_unhalted_cpus, cpu_active_mask, cpu_halt_mask);
if (cpumask_weight(&active_unhalted_cpus) == 0) {
/*
* there must be at least one active unhalted cpu in the system
* if not, blanket allow this cpu, regardless of halt status
*/
*allowed = true;
return;
}
}
}
}