Re: [PATCH v33 5/7] sched/proxy: Break cyclic proxy chains by deactivating blocked tasks
From: Kayra Cizmeci
Date: Sat Oct 24 2026 - 17:20:16 EST
On Fri, Oct 23, 2026 at 10:04:16PM +0000, John Stultz wrote:
> From: "zhidao su (Xiaomi)" <soolaugust@xxxxxxxxx>
>
> find_proxy_task() follows the blocked_on/owner chain for a
> blocked donor. If the chain forms a cycle, __schedule() can keep
> walking the same chain while holding rq->lock.
> Signed-off-by: zhidao su (Xiaomi) <soolaugust@xxxxxxxxx>
> [jstultz: Simplified slightly, dropping WARN_ON and owner == donor
> check, slightly reworked commit message]
> Signed-off-by: John Stultz <jstultz@xxxxxxxxxx>
> ---
> kernel/sched/core.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 43ba76b5a3464..12a42252bf474 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -6984,6 +6984,8 @@ static void proxy_migrate_task(struct rq *rq, struct rq_flags *rf,
> proxy_reacquire_rq_lock(rq, rf);
> }
>
> +#define MAX_PROXY_CHAIN_DEPTH 1024
> +
> /*
> * Find runnable lock owner to proxy for mutex blocked donor
> *
> @@ -7019,6 +7021,7 @@ find_proxy_task(struct rq *rq, struct task_struct *donor, struct rq_flags *rf)
> int this_cpu = cpu_of(rq);
> struct task_struct *p;
> int owner_cpu;
> + int chain_depth = 0;
>
> /* Follow blocked_on chain. */
> for (p = donor; p->is_blocked; p = owner) {
> @@ -7139,6 +7142,13 @@ find_proxy_task(struct rq *rq, struct task_struct *donor, struct rq_flags *rf)
> */
> goto resched_idle;
> }
> +
> + /* Limit the depth we'll proxy to avoid cyclic deadlocks */
> + if (++chain_depth > MAX_PROXY_CHAIN_DEPTH) {
> + __clear_task_blocked_on(p, NULL);
> + goto deactivate;
> + }
> +
> /*
> * OK, now we're absolutely sure @owner is on this
> * rq, therefore holding @rq->lock is sufficient to
> --
> 2.56.0.257.gf7497c7d27-goog
>
This needs a Fixes tag, no?
Fixes: 7de9d4f94638 ("sched: Start blocked_on chain processing in find_proxy_task()")