Skip to content

Commit 3546119

Browse files
committed
sched_ext: Refactor do_enqueue_task() local and global DSQ paths
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>
1 parent bfd3749 commit 3546119

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

kernel/sched/ext.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,7 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
12791279
{
12801280
struct scx_sched *sch = scx_root;
12811281
struct task_struct **ddsp_taskp;
1282+
struct scx_dispatch_q *dsq;
12821283
unsigned long qseq;
12831284

12841285
WARN_ON_ONCE(!(p->scx.flags & SCX_TASK_QUEUED));
@@ -1346,23 +1347,25 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
13461347
direct:
13471348
direct_dispatch(sch, p, enq_flags);
13481349
return;
1349-
1350+
local_norefill:
1351+
dispatch_enqueue(sch, &rq->scx.local_dsq, p, enq_flags);
1352+
return;
13501353
local:
1354+
dsq = &rq->scx.local_dsq;
1355+
goto enqueue;
1356+
global:
1357+
dsq = find_global_dsq(sch, p);
1358+
goto enqueue;
1359+
1360+
enqueue:
13511361
/*
13521362
* For task-ordering, slice refill must be treated as implying the end
13531363
* of the current slice. Otherwise, the longer @p stays on the CPU, the
13541364
* higher priority it becomes from scx_prio_less()'s POV.
13551365
*/
13561366
touch_core_sched(rq, p);
13571367
refill_task_slice_dfl(sch, p);
1358-
local_norefill:
1359-
dispatch_enqueue(sch, &rq->scx.local_dsq, p, enq_flags);
1360-
return;
1361-
1362-
global:
1363-
touch_core_sched(rq, p); /* see the comment in local: */
1364-
refill_task_slice_dfl(sch, p);
1365-
dispatch_enqueue(sch, find_global_dsq(sch, p), p, enq_flags);
1368+
dispatch_enqueue(sch, dsq, p, enq_flags);
13661369
}
13671370

13681371
static bool task_runnable(const struct task_struct *p)

0 commit comments

Comments
 (0)