Re: [PATCH v34 03/14] sched/proxy: Reschedule when a blocked task is woken under a proxy
From: John Stultz
Date: Wed Dec 02 2026 - 01:33:19 EST
On Tue, Dec 1, 2026 at 10:24 PM K Prateek Nayak <kprateek.nayak@xxxxxxx> wrote:
>
> Hello John,
>
> On 12/2/2026 11:36 AM, John Stultz wrote:
> > On Tue, Dec 1, 2026 at 9:06 PM K Prateek Nayak <kprateek.nayak@xxxxxxx> wrote:
> >> On 12/2/2026 10:30 AM, K Prateek Nayak wrote:
> >>> We can perhaps re-arrange the checks in proxy_needs_return() as:
> >>>
> >>> if (task_current(rq, p)) /* implies p->on_cpu && task_cpu(p) == p->wake_cpu */
> >>> return false;
> >>>
> >>> if (task_current_donor(rq, p)
> >>> proxy_reset_donor(rq)
> >>>
> >>> if (task_cpu(p) == p->wake_cpu && !rt_dl_task(p))
> >>> return false;
> >>>
> >>> /* Do the dequeue; Don't touch p->blocked_on. */
> >>
> >> So the enqueue_task_rt() and enqueue_task_dl() do actually look
> >> at p->blocked_on to queue that balance callback so I guess that
> >> clearing is needed after all.
> >>
> >> But the re-ordering should be still fine - if task_current() is
> >> true we still haven't lost to schedule and the task is still
> >> queued on the original rq.
> >
> > So just that I'm understanding you properly, the idea is just to
> > rework the logic currently done under the blocked_lock, so after the
> > patches in this series, proxy_needs_return() would look like:
> >
> > {
> > proxy_clear_curr_donor(rq, p);
> > if (rq->donor != rq->curr)
> > resched_curr(rq);
> >
> > if (task_current(rq, p))
> > return false;
> >
> > if (task_cpu(p) == p->wake_cpu && !rt_or_dl_task(p))
> > return false;
> >
> > if (task_current_donor(rq, p))
> > proxy_reset_donor(rq);
> >
> > clear_task_blocked_on(p, NULL);
> > block_task(rq, p, TASK_WAKING, 0);
> > }
> >
> > ?
>
> Almost! what I thought looks like:
>
> {
> if (task_current(rq, p))
> return false;
>
> if (task_current_donor(rq, p))
> proxy_reset_donor(rq); /* Do proxy_clear_curr_donor() within */
I don't think that would work. If there'a a chain A->B->C where A is
the donor, and C is curr. If B wakes up, we need to do the
proxy_clear_curr_donor() (since its C's->blocked_donor).
If we hide that under a task_current_donor() conditional, we'll only
call it if p==A.
Also, your example skipped the:
if (rq->donor != rq->curr)
resched_curr(rq);
bit which is what the patch at the start of this thread is focused on.
> if (task_cpu(p) == p->wake_cpu && !rt_or_dl_task(p))
> return false;
>
> clear_task_blocked_on(p, NULL);
> block_task(rq, p, TASK_WAKING, 0);
> }
>
> > I'll give that a shot here.
> >
> > I'm wondering if a if (!sched_proxy_exec()) return; shortcut at the
> > top might be nice too since we may not want to trip up the rt/dl task
> > case and do all the work, but I know Peter wasn't happy with that
> > being sprinkled around.
>
> Ack! That makes sense given the rt_or_dl_task() condition.
I'll add that in as well then. The reordering/reworking the logic
feels separate enough I'll do it in a separate patch from the original
change here from Mathieu.
thanks
-john