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 - 01:24:28 EST


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 */

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.

--
Thanks and Regards,
Prateek