]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched_ext: Refactor do_enqueue_task() local and global DSQ paths
authorTejun Heo <tj@kernel.org>
Tue, 11 Nov 2025 19:18:05 +0000 (09:18 -1000)
committerTejun Heo <tj@kernel.org>
Wed, 12 Nov 2025 16:43:44 +0000 (06:43 -1000)
The local and global DSQ enqueue paths in do_enqueue_task() share the same
slice refill logic. Factor out the common code into a shared enqueue label.
This makes adding new enqueue cases easier. No functional changes.

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

index 1a9b28dd0961b9ed401a9d5ebc1468642113d164..43083602c15e38be06439386faa09f50367b2e79 100644 (file)
@@ -1279,6 +1279,7 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
 {
        struct scx_sched *sch = scx_root;
        struct task_struct **ddsp_taskp;
+       struct scx_dispatch_q *dsq;
        unsigned long qseq;
 
        WARN_ON_ONCE(!(p->scx.flags & SCX_TASK_QUEUED));
@@ -1346,8 +1347,17 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
 direct:
        direct_dispatch(sch, p, enq_flags);
        return;
-
+local_norefill:
+       dispatch_enqueue(sch, &rq->scx.local_dsq, p, enq_flags);
+       return;
 local:
+       dsq = &rq->scx.local_dsq;
+       goto enqueue;
+global:
+       dsq = find_global_dsq(sch, p);
+       goto enqueue;
+
+enqueue:
        /*
         * For task-ordering, slice refill must be treated as implying the end
         * of the current slice. Otherwise, the longer @p stays on the CPU, the
@@ -1355,14 +1365,7 @@ local:
         */
        touch_core_sched(rq, p);
        refill_task_slice_dfl(sch, p);
-local_norefill:
-       dispatch_enqueue(sch, &rq->scx.local_dsq, p, enq_flags);
-       return;
-
-global:
-       touch_core_sched(rq, p);        /* see the comment in local: */
-       refill_task_slice_dfl(sch, p);
-       dispatch_enqueue(sch, find_global_dsq(sch, p), p, enq_flags);
+       dispatch_enqueue(sch, dsq, p, enq_flags);
 }
 
 static bool task_runnable(const struct task_struct *p)