Re: [PATCH 1/3] selftests/sched_ext: Add a test for ops.dequeue() on remote local DSQ moves

From: Andrea Righi

Date: Tue Sep 29 2026 - 14:43:05 EST


Hi Kuba,

On Tue, Sep 29, 2026 at 04:17:24PM +0000, Kuba Piecuch wrote:
> When a BPF scheduler moves a task that is in its custody to the local DSQ
> of a CPU other than the one whose rq the task is on, sched_ext migrates the
> task with move_remote_task_to_local_dsq(). The task leaves the BPF
> scheduler's custody when it is inserted into the destination local DSQ and
> ops.dequeue() should be called at that point, just like for same-rq
> dispatches.
>
> Add a dequeue_remote test that exercises this path. All tasks are put
> into custody from ops.enqueue() and moved to the local DSQ of whichever
> CPU runs ops.dispatch(), so that most moves cross CPUs. Two variants are
> covered, selected by test_use_move_to_local:
>
> - false: tasks are queued in a BPF queue and dispatched with
> scx_bpf_dsq_insert(SCX_DSQ_LOCAL_ON | cpu), going through
> dispatch_to_local_dsq(),
>
> - true: tasks are queued on a user DSQ and consumed with
> scx_bpf_dsq_move_to_local(), going through consume_remote_task().
>
> The BPF scheduler tracks each task's custody state and triggers
> scx_bpf_error() if:
>
> - ops.dequeue() is called with SCX_DEQ_CORE_SCHED_EXEC, meaning that
> the custody exit was missed on insertion into the local DSQ and
> deferred to set_next_task_scx(),
>
> - a task starts running without ops.dequeue() having been called since
> its last ops.enqueue(),
>
> - ops.dequeue() is called for a task that isn't in custody, or
> ops.enqueue() for a task that is.
>
> Core scheduling can legitimately pick tasks straight out of custody, so
> the test is skipped if any task has a core scheduling cookie when it
> starts.
>
> The test currently fails:
>
> sched_ext: dequeue_remote: dequeue_remote.bpf.c:143: 156 (runner): late ops.dequeue() with SCX_DEQ_CORE_SCHED_EXEC (enq_cpu=1 cpu=3 seq=1)
> ...
> ops_dequeue+0x114/0x170
> set_next_task_scx+0x104/0x1e0
> __pick_next_task+0xc7/0x180
> __schedule+0x154/0x1870
>
> so don't add it to auto-test-targets yet. It will be enabled once the
> underlying bug is fixed.
>
> Assisted-by: Claude:claude-opus-5.5
> Signed-off-by: Kuba Piecuch <jpiecuch@xxxxxxxxxx>

We can probably fold the this into PATCH 3.

Thanks,
-Andrea