Re: [PATCH v34 03/14] sched/proxy: Reschedule when a blocked task is woken under a proxy
From: K Prateek Nayak
Date: Wed Dec 02 2026 - 00:00:44 EST
Hello John,
On 12/2/2026 9:22 AM, John Stultz wrote:
> From: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
>
> With proxy execution, a task blocked on a mutex stays on its runqueue.
> The scheduler can pick it as the donor and run the mutex owner in its
> place. When the donor is woken, the CPU must stop running the owner on
> the donor's context.
>
> Commit 7918cf369361 ("sched/proxy: Only return migrate when needed")
> wakes a blocked task in place when it is still on its original CPU.
> ttwu_runnable() then relies on wakeup_preempt() to preempt the running
> task. But every class compares the woken task with rq->donor. When the
> woken task is the donor, it compares the task with itself, and no
> reschedule is requested. Only sched_ext handles this, with WF_TTWU_RQ.
Question: proxy_needs_return() needed to grab the &p->blocked_lock to
clear the p->blocked_on relationship previously but now that we have the
p->is_blocked state, we probably don't have to touch p->blocked_on at
all - a successful lock acquisition will clear it on the way out of
mutex_lock_common().
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. */
That should automatically allow ttwu_runnable() calling
wakeup_preempt() to do the right thing and since p->blocked_on is
only used to traverse chain if p->is_blocked is true first, there
should be no harm to retain that.
One of the fist thing that is done when the task runs on CPU is to
re-establish that blocked_on relation which doesn't change now. Is
there any harm in retaining it?
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 181d0e70c88d4..9ba25925c928a 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3981,6 +3981,14 @@ static int ttwu_runnable(struct task_struct *p, int wake_flags)
> if (p->is_blocked) {
> if (p->se.sched_delayed)
> enqueue_task(rq, p, ENQUEUE_NOCLOCK | ENQUEUE_DELAYED);
> + /*
> + * If we're waking a blocked task and we are
> + * currently proxying, force a resched in case
> + * the woken task p is in the current donor chain
> + */
> + if (rq->donor != rq->curr)
> + resched_curr(rq);
> +
Principally, I don't have problem with this approach but being able
to keep all the proxy related handling contained in
proxy_needs_return() below would be nice :-)
> if (proxy_needs_return(rq, p))
> return 0;
> }
--
Thanks and Regards,
Prateek