]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched_ext: Skip tasks with stale task_rq in bypass_lb_cpu()
authorTejun Heo <tj@kernel.org>
Sat, 25 Apr 2026 00:31:35 +0000 (14:31 -1000)
committerTejun Heo <tj@kernel.org>
Sat, 25 Apr 2026 00:31:35 +0000 (14:31 -1000)
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 <clm@meta.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
kernel/sched/ext.c

index 68c67113204fa8c95242b5ba19ac20ade6a72c6a..f8500ce37b227130f460c9119a0e02687a6669ce 100644 (file)
@@ -5023,6 +5023,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) != @donor_rq. @p can't be moved
+                * without its rq locked. Skip.
+                */
+               if (task_rq(p) != donor_rq)
+                       continue;
+
                donee = cpumask_any_and_distribute(donee_mask, p->cpus_ptr);
                if (donee >= nr_cpu_ids)
                        continue;