sched/walt: Ensure always in state2 if no partial halted CPUs

is_state1 is supposed to return true, if and only if all CPUs that are
capable of being partially halted are either partially halted or fully
halted.

In the event that there are no partially halted CPUs in a system,
meaning min_partial_cpus is defined as 0, the expectation is for
is_state1 to return false.

However, cpumask_subset will return true if the first source CPU mask is
empty. This leads to unexpected behavior, as it would result in a case
where the system is always under state1 when min_partial_cpus is set to
0, resulting in a side effect where frequencies would never be synced.

Fix this by ensuring that if the number of CPUs that are capable of
being partially halted is 0, is_state1 returns false, thereby ensuring
that in such a system, state2, and therefore frequency sync, is always
the norm.

Change-Id: I2fb7cf27659d42fe713bdacf08db9b7c88c06800
Signed-off-by: Shaleen Agrawal <quic_shalagra@quicinc.com>
This commit is contained in:
Shaleen Agrawal 2023-08-21 10:35:56 -07:00
parent bd7da87cc2
commit 7acd4b7dba

View File

@ -1021,6 +1021,9 @@ static inline bool is_state1(void)
{
struct cpumask local_mask = { CPU_BITS_NONE };
if (!cpumask_weight(&part_haltable_cpus))
return false;
cpumask_or(&local_mask, cpu_partial_halt_mask, cpu_halt_mask);
return cpumask_subset(&part_haltable_cpus, &local_mask);
}