Re: [PATCH 02/12] sched/core: Skip put_prev_task/set_next_task re-entry for sched_ext donors
From: Peter Zijlstra
Date: Thu Jul 02 2026 - 14:24:20 EST
On Thu, Jul 02, 2026 at 07:09:18PM +0200, Andrea Righi wrote:
> In __schedule(), the proxy-exec donor-stabilization block calls
> put_prev_task() and set_next_task() when rq->donor == prev_donor and
> prev != next.
>
> For sched_ext tasks, re-entering set_next_task_scx() for a donor that
> has already been seen by BPF ops.running via the normal pick path causes
> issues. It fires SCX_CALL_OP_TASK(sch, running, rq, donor) a second
> time, and sch->ops dispatch can land on a vtable slot in a state that
> yields a NULL function pointer or corrupts the stack.
>
> Fix this by skipping the put_prev_task/set_next_task re-entry when the
> donor is in the ext_sched_class, since sched_ext tracks curr/donor
> itself.
This really sounds like a bug in ext; how is this different from the
sched_change pattern doing a put/set cycle?