@@ -4489,11 +4489,16 @@ static void scx_ops_disable_workfn(struct kthread_work *work)
4489
4489
scx_task_iter_start (& sti );
4490
4490
while ((p = scx_task_iter_next_locked (& sti ))) {
4491
4491
const struct sched_class * old_class = p -> sched_class ;
4492
+ const struct sched_class * new_class =
4493
+ __setscheduler_class (p -> policy , p -> prio );
4492
4494
struct sched_enq_and_set_ctx ctx ;
4493
4495
4496
+ if (old_class != new_class && p -> se .sched_delayed )
4497
+ dequeue_task (task_rq (p ), p , DEQUEUE_SLEEP | DEQUEUE_DELAYED );
4498
+
4494
4499
sched_deq_and_put_task (p , DEQUEUE_SAVE | DEQUEUE_MOVE , & ctx );
4495
4500
4496
- p -> sched_class = __setscheduler_class ( p -> policy , p -> prio ) ;
4501
+ p -> sched_class = new_class ;
4497
4502
check_class_changing (task_rq (p ), p , old_class );
4498
4503
4499
4504
sched_enq_and_set_task (& ctx );
@@ -5199,12 +5204,17 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
5199
5204
scx_task_iter_start (& sti );
5200
5205
while ((p = scx_task_iter_next_locked (& sti ))) {
5201
5206
const struct sched_class * old_class = p -> sched_class ;
5207
+ const struct sched_class * new_class =
5208
+ __setscheduler_class (p -> policy , p -> prio );
5202
5209
struct sched_enq_and_set_ctx ctx ;
5203
5210
5211
+ if (old_class != new_class && p -> se .sched_delayed )
5212
+ dequeue_task (task_rq (p ), p , DEQUEUE_SLEEP | DEQUEUE_DELAYED );
5213
+
5204
5214
sched_deq_and_put_task (p , DEQUEUE_SAVE | DEQUEUE_MOVE , & ctx );
5205
5215
5206
5216
p -> scx .slice = SCX_SLICE_DFL ;
5207
- p -> sched_class = __setscheduler_class ( p -> policy , p -> prio ) ;
5217
+ p -> sched_class = new_class ;
5208
5218
check_class_changing (task_rq (p ), p , old_class );
5209
5219
5210
5220
sched_enq_and_set_task (& ctx );
0 commit comments