@@ -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