Re: [PATCH 05/39] sched: Add sched_class->switching_to() and expose check_class_changing/changed()

Peter Zijlstra
2024-06-25T08:16:57Z

On Mon, Jun 24, 2024 at 12:18:07PM -1000, Tejun Heo wrote:
> Hello, Peter.
>
> On Mon, Jun 24, 2024 at 01:06:24PM +0200, Peter Zijlstra wrote:
> ...
> > > + void (*switching_to) (struct rq *this_rq, struct task_struct *task);
> > > void (*switched_from)(struct rq *this_rq, struct task_struct *task);
> > > void (*switched_to) (struct rq *this_rq, struct task_struct *task);
> >
> > So I *think* that I can handle all the current cases in
> > sched_class::{en,de}queue_task() if we add {EN,DE}QUEUE_CLASS flags.
> >
> > Would that work for the BPF thing as well?
> >
> > Something like the very much incomplete below... It would allow removing
> > all these switch{ed,ing}_{to,from}() things entirely, instead of
> > adding yet more.
>
> Hmm... so, I tried to make it work for SCX but enqueue() and dequeue() are
> only called if the task was queued at the time of sched_class change, right?
> However, these callbacks expect to be called even when the task is not
> currently queued. Maybe I'm misreading code but it looks like that'd break
> other classes too. What am I missing?

Ah,.. so I think the RT/DL ones can work (which is what I looked at),
they're only concerned with balancing tasks that are on the queue.
But yeah, I missed that the fair thing needs it regardless.

Bummer. I was hoping to reduce calls.