]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched_ext: Pass full dequeue flags to ops.quiescent()
authorAndrea Righi <arighi@nvidia.com>
Sat, 7 Mar 2026 09:56:31 +0000 (10:56 +0100)
committerTejun Heo <tj@kernel.org>
Sat, 7 Mar 2026 15:09:23 +0000 (05:09 -1000)
ops.quiescent() is invoked with the same deq_flags as ops.dequeue(), so
the BPF scheduler is able to distinguish sleep vs property changes in
both callbacks.

However, dequeue_task_scx() receives deq_flags as an int from the
sched_class interface, so SCX flags above bit 32 (%SCX_DEQ_SCHED_CHANGE)
are truncated. ops_dequeue() reconstructs the full u64 for ops.dequeue(),
but ops.quiescent() is still called with the original int and can never
see %SCX_DEQ_SCHED_CHANGE.

Fix this by constructing the full u64 deq_flags in dequeue_task_scx()
(renaming the int parameter to core_deq_flags) and passing the complete
flags to both ops_dequeue() and ops.quiescent().

Fixes: ebf1ccff79c4 ("sched_ext: Fix ops.dequeue() semantics")
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c

index 72b7a87f66ec9819653ecd5c288264fef4b0a000..47f65041b363d3d42614a40136460ae88148d2f3 100644 (file)
@@ -1782,14 +1782,6 @@ static void ops_dequeue(struct rq *rq, struct task_struct *p, u64 deq_flags)
 {
        struct scx_sched *sch = scx_task_sched(p);
        unsigned long opss;
-       u64 op_deq_flags = deq_flags;
-
-       /*
-        * Set %SCX_DEQ_SCHED_CHANGE when the dequeue is due to a property
-        * change (not sleep or core-sched pick).
-        */
-       if (!(op_deq_flags & (DEQUEUE_SLEEP | SCX_DEQ_CORE_SCHED_EXEC)))
-               op_deq_flags |= SCX_DEQ_SCHED_CHANGE;
 
        /* dequeue is always temporary, don't reset runnable_at */
        clr_task_runnable(p, false);
@@ -1846,12 +1838,20 @@ static void ops_dequeue(struct rq *rq, struct task_struct *p, u64 deq_flags)
         * NONE but the task may still have %SCX_TASK_IN_CUSTODY set until
         * it is enqueued on the destination.
         */
-       call_task_dequeue(sch, rq, p, op_deq_flags);
+       call_task_dequeue(sch, rq, p, deq_flags);
 }
 
-static bool dequeue_task_scx(struct rq *rq, struct task_struct *p, int deq_flags)
+static bool dequeue_task_scx(struct rq *rq, struct task_struct *p, int core_deq_flags)
 {
        struct scx_sched *sch = scx_task_sched(p);
+       u64 deq_flags = core_deq_flags;
+
+       /*
+        * Set %SCX_DEQ_SCHED_CHANGE when the dequeue is due to a property
+        * change (not sleep or core-sched pick).
+        */
+       if (!(deq_flags & (DEQUEUE_SLEEP | SCX_DEQ_CORE_SCHED_EXEC)))
+               deq_flags |= SCX_DEQ_SCHED_CHANGE;
 
        if (!(p->scx.flags & SCX_TASK_QUEUED)) {
                WARN_ON_ONCE(task_runnable(p));