Re: [RFC PATCH v1 3/8] sched/proxy: Stop the chain walk when the blocked_on chain is a cycle

From: John Stultz

Date: Mon Nov 16 2026 - 15:37:02 EST


On Mon, Nov 16, 2026 at 11:26 AM Mathieu Desnoyers
<mathieu.desnoyers@xxxxxxxxxxxx> wrote:
>
> find_proxy_task() follows the blocked_on chain from the donor to a task
> that can run. It holds the rq lock, with interrupts off. It has no bound
> on the number of steps.
>
> The walk relies on the chain having an end. The ww_mutex die and wound
> paths clear blocked_on for that reason. Their comments say that circular
> blocked_on relationships would not resolve otherwise. But two tasks that
> take two plain mutexes in opposite orders deadlock for good. Once both
> are on one runqueue, the walk goes around the cycle forever.
>
> Without proxy execution, such a deadlock leaves two tasks asleep, and
> the hung task detector can report them. With it, the CPU locks up with
> its rq lock held. Other CPUs would then block on that lock. In a test
> with two CPUs, the guest stopped without a message.
>
> Fix this by detecting the cycle. The walk remembers the task it met at
> its last step that is a power of two. When it meets that task again, it
> stops the donation and deactivates the donor. The donor then sleeps on
> its mutex, as without proxy execution.
>
> Fixes: 7de9d4f94638 ("sched: Start blocked_on chain processing in find_proxy_task()")
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
> ---
> kernel/sched/core.c | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)


So this looks like it duplicates the following two changes in my series:
https://lore.kernel.org/lkml/20261023220431.1106611-6-jstultz@xxxxxxxxxx/
https://lore.kernel.org/lkml/20261023220431.1106611-7-jstultz@xxxxxxxxxx/

And I've recently found there's a few other spots that we need to
bound chain walking (though I believe those additional cases are still
out of tree in the full proxy-exec series).

thanks
-john