Re: [RFC][PATCH 6/6] sched: Cleanup sched_delayed handling for class switches

From: Peter Zijlstra
Date: Wed Oct 30 2024 - 11:46:06 EST


On Wed, Oct 30, 2024 at 04:13:01PM +0100, Peter Zijlstra wrote:

> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c

> @@ -5202,7 +5200,7 @@ static int scx_ops_enable(struct sched_e
> percpu_down_write(&scx_fork_rwsem);
> scx_task_iter_start(&sti);
> while ((p = scx_task_iter_next_locked(&sti))) {
> - unsigned int queue_flags = DEQUEUE_SAVE | DEQUEUE_MOVE;
> + unsigned int queue_flags = DEQUEUE_SAVE | DEQUEUE_MOVE | DEQUEUE_NOCLOCK;
> const struct sched_class *old_class = p->sched_class;
> const struct sched_class *new_class =
> __setscheduler_class(p->policy, p->prio);
> @@ -5210,9 +5208,7 @@ static int scx_ops_enable(struct sched_e
> if (old_class != new_class)
> queue_flags |= DEQUEUE_CLASS;
>
> - if (old_class != new_class && p->se.sched_delayed)
> - dequeue_task(task_rq(p), p, DEQUEUE_SLEEP | DEQUEUE_DELAYED);
> -
> + update_rq_clock(task_rq(p));
> scoped_guard (sched_change, p, DEQUEUE_SAVE | DEQUEUE_MOVE) {
> p->scx.slice = SCX_SLICE_DFL;
> p->sched_class = new_class;

TJ, strictly speaking you should probably do a __balance_callbacks() in
__scx_task_irq_rq_unlock(). The various switched_from() methods like to
queue_balance_callback().

I think you're currently good by the fact that only RT/DL do this, and
you're not touching those in these loops.