Skip to content

Commit d5776a3

Browse files
htejungregkh
authored andcommitted
sched_ext: Refactor do_enqueue_task() local and global DSQ paths
[ Upstream commit 3546119 ] 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> Stable-dep-of: 7e0ffb7 ("sched_ext: Fix stale direct dispatch state in ddsp_dsq_id") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9e36ceb commit d5776a3

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
@@ -1243,6 +1243,7 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
12431243
{
12441244
struct scx_sched *sch = scx_root;
12451245
struct task_struct **ddsp_taskp;
1246+
struct scx_dispatch_q *dsq;
12461247
unsigned long qseq;
12471248

12481249
WARN_ON_ONCE(!(p->scx.flags & SCX_TASK_QUEUED));
@@ -1310,23 +1311,25 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
13101311
direct:
13111312
direct_dispatch(sch, p, enq_flags);
13121313
return;
1313-
1314+
local_norefill:
1315+
dispatch_enqueue(sch, &rq->scx.local_dsq, p, enq_flags);
1316+
return;
13141317
local:
1318+
dsq = &rq->scx.local_dsq;
1319+
goto enqueue;
1320+
global:
1321+
dsq = find_global_dsq(sch, p);
1322+
goto enqueue;
1323+
1324+
enqueue:
13151325
/*
13161326
* For task-ordering, slice refill must be treated as implying the end
13171327
* of the current slice. Otherwise, the longer @p stays on the CPU, the
13181328
* higher priority it becomes from scx_prio_less()'s POV.
13191329
*/
13201330
touch_core_sched(rq, p);
13211331
refill_task_slice_dfl(sch, p);
1322-
local_norefill:
1323-
dispatch_enqueue(sch, &rq->scx.local_dsq, p, enq_flags);
1324-
return;
1325-
1326-
global:
1327-
touch_core_sched(rq, p); /* see the comment in local: */
1328-
refill_task_slice_dfl(sch, p);
1329-
dispatch_enqueue(sch, find_global_dsq(sch, p), p, enq_flags);
1332+
dispatch_enqueue(sch, dsq, p, enq_flags);
13301333
}
13311334

13321335
static bool task_runnable(const struct task_struct *p)

0 commit comments

Comments
 (0)