Re: [PATCH 2/2] selftests/sched_ext: Make allowed_cpus idle validation race-free

From: Kuba Piecuch

Date: Sat Aug 01 2026 - 06:37:26 EST


On Fri Jul 31, 2026 at 3:26 PM UTC, Andrea Righi wrote:
> On Fri, Jul 31, 2026 at 11:12:09AM +0000, Kuba Piecuch wrote:
>> Could we check a stronger invariant by also checking that the bit in the idle
>> mask is set if we're running an idle task? We can get the idle cpumask through
>> scx_bpf_get_idle_cpumask() and check bits without clearing them using
>> bpf_cpumask_test_cpu().
>
> I don't think the other direction always holds: an idle CPU can be claimed by
> another BPF idle CPU selection helper, which can clear the idle bit before the
> CPU necessarily stops running the idle task. In that case, observing an idle
> task with a clear idle bit is legitimate.

Right, thanks for pointing that out.