On Mon, Mar 02, 2026 at 02:48:51PM +0800, Feng Yang wrote:
> From: Feng Yang <[email protected]>
> 
> When __COMPAT_scx_bpf_pick_idle_cpu_node selects an idle CPU,
> it reports that the CPU should be marked as busy.
> 
> Fixes: 5ae5161820e5 ("selftests/sched_ext: Add NUMA-aware scheduler test")
> Signed-off-by: Feng Yang <[email protected]>
> ---
>  tools/testing/selftests/sched_ext/numa.bpf.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/sched_ext/numa.bpf.c 
> b/tools/testing/selftests/sched_ext/numa.bpf.c
> index a79d86ed54a1..98423628b05c 100644
> --- a/tools/testing/selftests/sched_ext/numa.bpf.c
> +++ b/tools/testing/selftests/sched_ext/numa.bpf.c
> @@ -44,12 +44,12 @@ s32 BPF_STRUCT_OPS(numa_select_cpu,
>        */
>       cpu = __COMPAT_scx_bpf_pick_idle_cpu_node(p->cpus_ptr, node,
>                                       __COMPAT_SCX_PICK_IDLE_IN_NODE);
> -     if (cpu < 0)
> +     if (cpu < 0) {
>               cpu = __COMPAT_scx_bpf_pick_any_cpu_node(p->cpus_ptr, node,
>                                               __COMPAT_SCX_PICK_IDLE_IN_NODE);
> -
> -     if (is_cpu_idle(cpu, node))
> -             scx_bpf_error("CPU %d should be marked as busy", cpu);
> +             if (is_cpu_idle(cpu, node))
> +                     scx_bpf_error("CPU %d should be marked as busy", cpu);
> +     }

No, this is not correct. The CPU returned by scx_bpf_pick_idle_cpu_node()
should be marked as busy at this point (bit is set in the idle cpumask),
essentially it has been reserved/allocated by the caller.

Maybe we can add a comment if we think it's not clear enough, but the
original code looks correct.

>  
>       if (__COMPAT_scx_bpf_cpu_node(cpu) != node)
>               scx_bpf_error("CPU %d should be in node %d", cpu, node);
> -- 
> 2.43.0
> 

Thanks,
-Andrea

Reply via email to