Re: [PATCH v10 00/12] sched, steal_governor: Introduce preferred CPUs and steal-driven vCPU backoff
From: Dietmar Eggemann
Date: Thu Aug 27 2026 - 06:52:58 EST
Hi Shrikanth,
On 17.08.26 09:39, Shrikanth Hegde wrote:
> Hi.
>
> In addition to what's currently planned for v11 which was posted here,
> https://lore.kernel.org/all/895a058a-475e-42ca-
> a7a3-2c854598eea4@xxxxxxxxxxxxx/
>
> I was going through sashiko's comments at:
> https://sashiko.dev/#/patchset/20260812054033.95658-1-
> sshegde%40linux.ibm.com
> This has revealed some gaps. Thanks to some really nice insights too.
> Report quality improving day by day!
>
>
> Vincent, Dietmar, please check the 32-bit task issue fix on ARM64.
See below.
> On 8/12/26 11:10 AM, Shrikanth Hegde wrote:
[...]
> Issue1: Possible crash on 32-bit tasks on ARM64.
> =======
>>> +static inline bool task_can_sched_on_preferred(int cpu, struct
>>> task_struct *p)
>>> +{
>>> + if (cpu_preferred(cpu))
>>> + return false;
>>> +
>>> + /* Only FAIR tasks honor preferred CPU state */
>>> + if (unlikely(p->sched_class != &fair_sched_class))
>>> + return false;
>>> +
>>> + return cpumask_intersects(p->cpus_ptr, cpu_preferred_mask);
>>> +}
>> Does this intersection check need to account for the architectural CPU
>> mask?
>> On asymmetric systems, 32-bit tasks are architecturally restricted by
>> task_cpu_possible_mask(). If a 32-bit task's mask intersects with
>> 64-bit-only preferred CPUs, this function might return true, causing
>> is_cpu_allowed() to falsely return false for valid 32-bit non-
>> preferred CPUs.
>> Since 64-bit CPUs are rightfully rejected by task_allowed_on_cpu(),
>> all CPUs
>> end up rejected. Could this regression cause the select_fallback_rq()
>> loop
>> to exhaust all options and hit the BUG() case for 32-bit tasks?
>
> Fix:
> ====
> I wasn;t aware of this case, thanks to sashiko for bring it up.
> Yes, it could potentially cause a BUG in select_fallback_rq.
>
> Do a simple check if mask differ from possible mask which indicates we
> are on 32-bit task on 64 bit
> kernel. Do the below. I think that should solve it.
>
> static inline bool task_can_sched_on_preferred(int cpu, struct
> task_struct *p)
> {
> + const struct cpumask *valid_mask;
> + int i;
> [...]
> + valid_mask = task_cpu_possible_mask(p);
> + if (likely(valid_mask == cpu_possible_mask))
> + return cpumask_intersects(p->cpus_ptr, cpu_preferred_mask);
> +
> + /* 32-bit task */
> + for_each_cpu_and(i, p->cpus_ptr, cpu_preferred_mask) {
> + if (cpumask_test_cpu(i, valid_mask))
> + return true;
> + }
I assume the question is whether task_can_sched_on_preferred() would
have to be changed:
- return cpumask_intersects(p->cpus_ptr, cpu_preferred_mask);
+ return cpumask_first_and_and(p->cpus_ptr, cpu_preferred_mask,
+ task_cpu_possible_mask(p)) < nr_cpu_ids;
so that cpu_preferred_mask can play together nicely with the 'asymmetric
AArch32 EL0 (executing 32-bit Arm userspace under an AArch64 kernel)
support' feature on some mobile Arm64 Socs.
IMHO, this is not necessary since for those tasks p->cpus_ptr is always
a subset of task_cpu_possible_mask(p). 'p->cpus_ptr ∩
cpu_preferred_mask' already cannot contain an architecturally impossible
CPU for those 32-bit Arm userspace tasks.
[...]