Re: [PATCH 6/8] sched_ext: idle: Introduce scx_bpf_select_cpu_and()

From: Andrea Righi
Date: Sat Mar 15 2025 - 05:08:53 EST


Hi Changwoo,

On Sat, Mar 15, 2025 at 10:35:03AM +0900, Changwoo Min wrote:
> Hi Andrea,
...
> > +/**
> > + * scx_bpf_select_cpu_and - Pick an idle CPU usable by task @p,
> > + * prioritizing those in @cpus_allowed
> > + * @p: task_struct to select a CPU for
> > + * @prev_cpu: CPU @p was on previously
> > + * @wake_flags: %SCX_WAKE_* flags
> > + * @cpus_allowed: cpumask of allowed CPUs
> > + * @flags: %SCX_PICK_IDLE* flags
> > + *
> > + * Can only be called from ops.select_cpu() if the built-in CPU selection is
> > + * enabled - ops.update_idle() is missing or %SCX_OPS_KEEP_BUILTIN_IDLE is set.
> > + * @p, @prev_cpu and @wake_flags match ops.select_cpu().
>
> I think that scx_bpf_select_cpu_and () needs to be allowed to
> call from ops.enqueue(). That is because many scx schedulers have
> some logic similar to scx_bpf_select_cpu_dfl() to kick an idle
> CPU proactively.

That's a valid point, it can be a good opportunity to consolidate the logic
used in most schedulers, where the same "pick idle CPU" function is called
from both ops.select_cpu() and ops.enqueue() and have a unified core API
usable from both contexts.

I'll extend the scope of this kfunc to include ops.enqueue() in the next
version and run some tests with it.

Thanks!
-Andrea