Re: [RFC][PATCH 4/6] sched: Fold sched_class::switch{ing,ed}_{to,from}() into the change pattern

From: Tejun Heo
Date: Wed Oct 30 2024 - 17:13:02 EST


On Wed, Oct 30, 2024 at 04:12:59PM +0100, Peter Zijlstra wrote:
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -5199,20 +5204,24 @@ 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;
> const struct sched_class *old_class = p->sched_class;
> const struct sched_class *new_class =
> __setscheduler_class(p->policy, p->prio);
>
> + 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);
>
> scoped_guard (sched_change, p, DEQUEUE_SAVE | DEQUEUE_MOVE) {
^
queue_flags

> p->scx.slice = SCX_SLICE_DFL;
> p->sched_class = new_class;
> - check_class_changing(task_rq(p), p, old_class);
> }
>
> - check_class_changed(task_rq(p), p, old_class, p->prio);
> + if (!(queue_flags & DEQUEUE_CLASS))
> + check_prio_changed(task_rq(p), p, p->prio);

Maybe prio_changed can be moved into scoped_guard?

Thanks.

--
tejun