Skip to content

Commit 69d5e72

Browse files
author
Peter Zijlstra
committed
sched/ext: Fix scx vs sched_delayed
Commit 98442f0 ("sched: Fix delayed_dequeue vs switched_from_fair()") forgot about scx :/ Fixes: 98442f0 ("sched: Fix delayed_dequeue vs switched_from_fair()") Reported-by: Tejun Heo <tj@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lkml.kernel.org/r/20241030104934.GK14555@noisy.programming.kicks-ass.net
1 parent 5db9154 commit 69d5e72

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

kernel/sched/ext.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4489,11 +4489,16 @@ static void scx_ops_disable_workfn(struct kthread_work *work)
44894489
scx_task_iter_start(&sti);
44904490
while ((p = scx_task_iter_next_locked(&sti))) {
44914491
const struct sched_class *old_class = p->sched_class;
4492+
const struct sched_class *new_class =
4493+
__setscheduler_class(p->policy, p->prio);
44924494
struct sched_enq_and_set_ctx ctx;
44934495

4496+
if (old_class != new_class && p->se.sched_delayed)
4497+
dequeue_task(task_rq(p), p, DEQUEUE_SLEEP | DEQUEUE_DELAYED);
4498+
44944499
sched_deq_and_put_task(p, DEQUEUE_SAVE | DEQUEUE_MOVE, &ctx);
44954500

4496-
p->sched_class = __setscheduler_class(p->policy, p->prio);
4501+
p->sched_class = new_class;
44974502
check_class_changing(task_rq(p), p, old_class);
44984503

44994504
sched_enq_and_set_task(&ctx);
@@ -5199,12 +5204,17 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
51995204
scx_task_iter_start(&sti);
52005205
while ((p = scx_task_iter_next_locked(&sti))) {
52015206
const struct sched_class *old_class = p->sched_class;
5207+
const struct sched_class *new_class =
5208+
__setscheduler_class(p->policy, p->prio);
52025209
struct sched_enq_and_set_ctx ctx;
52035210

5211+
if (old_class != new_class && p->se.sched_delayed)
5212+
dequeue_task(task_rq(p), p, DEQUEUE_SLEEP | DEQUEUE_DELAYED);
5213+
52045214
sched_deq_and_put_task(p, DEQUEUE_SAVE | DEQUEUE_MOVE, &ctx);
52055215

52065216
p->scx.slice = SCX_SLICE_DFL;
5207-
p->sched_class = __setscheduler_class(p->policy, p->prio);
5217+
p->sched_class = new_class;
52085218
check_class_changing(task_rq(p), p, old_class);
52095219

52105220
sched_enq_and_set_task(&ctx);

0 commit comments

Comments
 (0)