]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched_ext: Make scx_prio_less() handle multiple schedulers
authorTejun Heo <tj@kernel.org>
Fri, 6 Mar 2026 17:58:03 +0000 (07:58 -1000)
committerTejun Heo <tj@kernel.org>
Fri, 6 Mar 2026 17:58:03 +0000 (07:58 -1000)
Call ops.core_sched_before() iff both tasks belong to the same scx_sched.
Otherwise, use timestamp based ordering.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
kernel/sched/ext.c

index 7741456e3cb0478e1d48384da023d619e1fa9751..e1fc2b1fc779ef4ff19eec8e94c34ca480722093 100644 (file)
@@ -2809,16 +2809,17 @@ void ext_server_init(struct rq *rq)
 bool scx_prio_less(const struct task_struct *a, const struct task_struct *b,
                   bool in_fi)
 {
-       struct scx_sched *sch = scx_root;
+       struct scx_sched *sch_a = scx_task_sched(a);
+       struct scx_sched *sch_b = scx_task_sched(b);
 
        /*
         * The const qualifiers are dropped from task_struct pointers when
         * calling ops.core_sched_before(). Accesses are controlled by the
         * verifier.
         */
-       if (SCX_HAS_OP(sch, core_sched_before) &&
+       if (sch_a == sch_b && SCX_HAS_OP(sch_a, core_sched_before) &&
            !scx_rq_bypassing(task_rq(a)))
-               return SCX_CALL_OP_2TASKS_RET(sch, SCX_KF_REST, core_sched_before,
+               return SCX_CALL_OP_2TASKS_RET(sch_a, SCX_KF_REST, core_sched_before,
                                              NULL,
                                              (struct task_struct *)a,
                                              (struct task_struct *)b);