Re: [PATCH 1/3] sched_ext: Fix ops_state and ops.dequeue() locking races in dispatch
From: Tejun Heo
Date: Tue Nov 24 2026 - 19:19:02 EST
Hello, Kuba.
On Mon, Nov 23, 2026 at 05:10:32PM +0000, Kuba Piecuch wrote:
> @@ -1871,8 +1884,10 @@ static void scx_dispatch_enqueue(struct scx_sched *sch, struct rq *rq,
>
> if (unlikely(dsq->id == SCX_DSQ_INVALID)) {
> scx_error(sch, "attempting to dispatch to a destroyed dsq");
> - /* fall back to the global dsq */
> raw_spin_unlock(&dsq->lock);
> + if (rq != task_rq(p))
> + return false;
> + /* fall back to the global dsq */
> dsq = find_global_dsq(sch, task_cpu(p));
> raw_spin_lock(&dsq->lock);
I don't think the task needs to go to the global DSQ here. The scheduler
is being ejected at this point and bypass is going to cycle all its
runnable tasks. Maybe we can just let go of the task and return, for both
the local and remote cases, and let the abort path recover it? What the
BPF scheduler sees after scx_error() doesn't matter as long as the
scheduler can be ejected and all the tasks are recovered. That'd get rid
of the bool return and the retry in finish_dispatch().
Also, can you please factor out release_dispatching_and_lock_task_rq()
from dispatch_to_local_dsq() in a separate prep patch?
The approach looks good to me otherwise. Can you please send v2 with the
above updated?
Thanks.
--
tejun