Skip to content

Commit 514d605

Browse files
htejungregkh
authored andcommitted
sched_ext: Factor out local_dsq_post_enq() from dispatch_enqueue()
commit 530b663 upstream. Factor out local_dsq_post_enq() which performs post-enqueue handling for local DSQs - triggering resched_curr() if SCX_ENQ_PREEMPT is specified or if the current CPU is idle. No functional change. This will be used by the next patch to fix move_local_task_to_local_dsq(). Cc: stable@vger.kernel.org # v6.12+ Reviewed-by: Andrea Righi <arighi@nvidia.com> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3192204 commit 514d605

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

kernel/sched/ext.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,22 @@ static void refill_task_slice_dfl(struct scx_sched *sch, struct task_struct *p)
906906
__scx_add_event(sch, SCX_EV_REFILL_SLICE_DFL, 1);
907907
}
908908

909+
static void local_dsq_post_enq(struct scx_dispatch_q *dsq, struct task_struct *p,
910+
u64 enq_flags)
911+
{
912+
struct rq *rq = container_of(dsq, struct rq, scx.local_dsq);
913+
bool preempt = false;
914+
915+
if ((enq_flags & SCX_ENQ_PREEMPT) && p != rq->curr &&
916+
rq->curr->sched_class == &ext_sched_class) {
917+
rq->curr->scx.slice = 0;
918+
preempt = true;
919+
}
920+
921+
if (preempt || sched_class_above(&ext_sched_class, rq->curr->sched_class))
922+
resched_curr(rq);
923+
}
924+
909925
static void dispatch_enqueue(struct scx_sched *sch, struct scx_dispatch_q *dsq,
910926
struct task_struct *p, u64 enq_flags)
911927
{
@@ -1003,22 +1019,10 @@ static void dispatch_enqueue(struct scx_sched *sch, struct scx_dispatch_q *dsq,
10031019
if (enq_flags & SCX_ENQ_CLEAR_OPSS)
10041020
atomic_long_set_release(&p->scx.ops_state, SCX_OPSS_NONE);
10051021

1006-
if (is_local) {
1007-
struct rq *rq = container_of(dsq, struct rq, scx.local_dsq);
1008-
bool preempt = false;
1009-
1010-
if ((enq_flags & SCX_ENQ_PREEMPT) && p != rq->curr &&
1011-
rq->curr->sched_class == &ext_sched_class) {
1012-
rq->curr->scx.slice = 0;
1013-
preempt = true;
1014-
}
1015-
1016-
if (preempt || sched_class_above(&ext_sched_class,
1017-
rq->curr->sched_class))
1018-
resched_curr(rq);
1019-
} else {
1022+
if (is_local)
1023+
local_dsq_post_enq(dsq, p, enq_flags);
1024+
else
10201025
raw_spin_unlock(&dsq->lock);
1021-
}
10221026
}
10231027

10241028
static void task_unlink_from_dsq(struct task_struct *p,

0 commit comments

Comments
 (0)