Re: [PATCH 3/3] sched_ext: Allow scx_bpf_reenqueue_local() to be called from anywhere

From: Tejun Heo
Date: Mon Oct 27 2025 - 12:11:58 EST


Hello,

On Mon, Oct 27, 2025 at 10:18:22AM +0100, Peter Zijlstra wrote:
...
> > The main use case for cpu_release() was calling scx_bpf_reenqueue_local() when
> > a CPU gets preempted by a higher priority scheduling class. However, the old
> > scx_bpf_reenqueue_local() could only be called from cpu_release() context.
>
> I'm a little confused. Isn't this the problem where balance_one()
> migrates a task to the local rq and we end up having to RETRY_TASK
> because another (higher) rq gets modified?

That's what I thought too and the gap between balance() and pick_task() can
be closed that way. However, while plugging that, I realized there's another
bigger gap between ttwu() and pick_task() because ttwu() can directly
dispatch a task into the local DSQ of a CPU. That one, there's no way to
close without a global hook.

> Why can't we simply re-queue the task in the RETRY_TASK branch --
> effectively undoing balance_one()?
>
> Relying on hooking into tracepoints seems like a gruesome hack.

>From a BPF scheduler's POV, it's just using a more generic mechanism.
Multiple schedulers already make use of other BPF attach points - timers,
TPs, fentry/fexit's, so this doesn't make things less congruent.

Thanks.

--
tejun