Re: [PATCH] sched_ext: Fix local_dsq_post_enq() to use task's scheduler in sub-sched

From: Cheng-Yang Chou

Date: Thu Apr 23 2026 - 00:37:58 EST


Hi zhidao,

On Thu, Apr 23, 2026 at 10:58:32AM +0800, zhidao su wrote:
> local_dsq_post_enq() calls call_task_dequeue() with scx_root instead of
> the scheduler instance actually managing the task. When
> CONFIG_EXT_SUB_SCHED is enabled, tasks may be managed by a sub-scheduler
> whose ops.dequeue() callback differs from root's. Using scx_root causes
> the wrong scheduler's ops.dequeue() to be consulted: sub-sched tasks
> dispatched to a local DSQ via scx_bpf_dsq_move_to_local() will have
> SCX_TASK_IN_CUSTODY cleared but the sub-scheduler's ops.dequeue() is
> never invoked, violating the custody exit semantics.
>
> Fix by adding a 'struct scx_sched *sch' parameter to local_dsq_post_enq()
> and move_local_task_to_local_dsq(), and propagating the correct scheduler
> from their callers dispatch_enqueue(), move_task_between_dsqs(), and
> consume_dispatch_q().
>
> This is consistent with dispatch_enqueue()'s non-local path which already
> passes 'sch' directly to call_task_dequeue() for global/bypass DSQs.
>
> Fixes: ebf1ccff79c4 ("sched_ext: Fix ops.dequeue() semantics")
> Signed-off-by: zhidao su <suzhidao@xxxxxxxxxx>

This fix looks correct for the parameter mismatch.

Reviewed-by: Cheng-Yang Chou <yphbchou0911@xxxxxxxxx>

Regarding the Fixes tag: I'm not entirely sure if it's strictly required
since the sub-scheduler groundwork is still a new feature. However, since
it fixes a specific logic error, keeping the tag seems appropriate.

Thanks.

--
Cheers,
Cheng-Yang