Re: [PATCH 08/20 v3] sched/fair: Add push task mechanism for fair

From: Vincent Guittot

Date: Fri Nov 13 2026 - 10:55:39 EST


On Fri, 13 Nov 2026 at 09:47, Li kunyu <likunyu@xxxxxxxxxxxxxx> wrote:
>
> Hi,
>
> On 2026/11/6 23:19, Vincent Guittot wrote:
> > /*
> > * select_task_rq_fair: Select a target runqueue for the task.
> > * There are 2 ways to select the target runqueue:
> > @@ -10552,6 +10712,18 @@ static void put_prev_task_fair(struct rq *rq, struct task_struct *prev, struct t
> > cfs_rq->curr = NULL;
> > if (se->on_rq)
> > __enqueue_entity(cfs_rq, se);
> > +
> > + if (next) {
> > + /*
> > + * The previous task might be eligible for being pushed on another cpu
> > + * if it is still active.
> > + */
> > + if (next != prev)
> > + fair_add_pushable_prev(rq, prev, next);
> > +
> > + if (next->sched_class != &fair_sched_class)
> > + fair_queue_push_tasks(rq);
> > + }
>
> Regarding if (next->sched_class != &fair_sched_class) - would it be more
> semantically correct to change it to if (sched_class_above(next->sched_class,
> &fair_sched_class))? The current code migrates all CFS tasks on the current rq
> whenever the next task is not of the fair class; I think it would be more
> appropriate to do this only when the next task has a higher scheduling priority.

I'm not sure to get your point.

We want to look for a possibly better CPU for prev when it's put back
in the runnable list. If next is a fair task we queue the call back in
set_next_task_fair() after having set next task but if next is not a
fair task, we queue the callback right now so it will be called after
swicthing to the not fair task.
That being said we can probably unconditionnaly queue it there

>
> I'm not sure whether my understanding is correct.
>
> --
> thanks,
> kunyu