From: Tejun Heo Date: Wed, 13 May 2026 13:01:11 +0000 (+0200) Subject: sched_ext: Skip tasks with stale task_rq in bypass_lb_cpu() X-Git-Tag: v7.0.9~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20096df92b7f83342377137da075663ba7469c42;p=thirdparty%2Fkernel%2Fstable.git sched_ext: Skip tasks with stale task_rq in bypass_lb_cpu() commit da2d81b4118a74e65d2335e221a38d665902a98c upstream. bypass_lb_cpu() transfers tasks between per-CPU bypass DSQs without migrating them - task_cpu() only updates when the donee later consumes the task via move_remote_task_to_local_dsq(). If the LB timer fires again before consumption and the new DSQ becomes a donor, @p is still on the previous CPU and task_rq(@p) != donor_rq. @p can't be moved without its own rq locked. Skip such tasks. Fixes: 95d1df610cdc ("sched_ext: Implement load balancer for bypass mode") Cc: stable@vger.kernel.org # v6.19+ Reported-by: Chris Mason Signed-off-by: Tejun Heo Reviewed-by: Andrea Righi [ arighi: replace donor_rq with rq, not present in v7.0.y ] Signed-off-by: Andrea Righi Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index a39b47febe6d..9c7ff5179e4f 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -4010,6 +4010,15 @@ resume: if (cpumask_empty(donee_mask)) break; + /* + * If an earlier pass placed @p on @donor_dsq from a different + * CPU and the donee hasn't consumed it yet, @p is still on the + * previous CPU and task_rq(@p) != @rq. @p can't be moved + * without its rq locked. Skip. + */ + if (task_rq(p) != rq) + continue; + donee = cpumask_any_and_distribute(donee_mask, p->cpus_ptr); if (donee >= nr_cpu_ids) continue;