Re: [PATCH] sched_ext: Always call put_prev_task() with scx enabled
From: Andrea Righi
Date: Mon Oct 14 2024 - 11:45:33 EST
On Mon, Oct 14, 2024 at 10:36:08AM +0200, Peter Zijlstra wrote:
...
> > @@ -2523,6 +2508,21 @@ DECLARE_STATIC_KEY_FALSE(__scx_switched_all); /* all fair class tasks on SCX */
> > #define scx_switched_all() false
> > #endif /* !CONFIG_SCHED_CLASS_EXT */
> >
> > +static inline void put_prev_set_next_task(struct rq *rq,
> > + struct task_struct *prev,
> > + struct task_struct *next)
> > +{
> > + WARN_ON_ONCE(rq->curr != prev);
> > +
> > + __put_prev_set_next_dl_server(rq, prev, next);
> > +
> > + if (next == prev && !scx_enabled())
> > + return;
>
> Does that not also want to include a 'next->sched_class ==
> &ext_sched_class' clause ? And a comment?
>
> > +
> > + prev->sched_class->put_prev_task(rq, prev, next);
> > + next->sched_class->set_next_task(rq, next, true);
> > +}
>
> And is there really no way scx can infer this happened? We just did pick
> after all, that can see this coming a mile of.
Ah, I believe I understand better what's happening now.
When prev == next with the idle class we're not calling
->put_prev_task/set_next_task anymore, so we may skip calling
ops.update_idle() in scx.
I think that's the only special case that we need to handle, and we may
be able to solve the regression by calling scx_update_idle() from
pick_task_idle().
Will do some testing with this.
-Andrea