Re: [PATCH v4] sched_ext: Trigger ops.update_idle() from pick_task_idle()
From: Andrea Righi
Date: Tue Oct 15 2024 - 18:13:23 EST
On Tue, Oct 15, 2024 at 05:31:09PM +0200, Andrea Righi wrote:
...
> > - For the purpose of determining whether a CPU is idle for e.g. task
> > placement from ops.select_cpu(). The CPU *should* be considered idle in
> > this polling state.
> >
> > Overall, it feels a bit contrived to generate update_idle() events
> > consecutively for this. If a scheduler wants to poll in idle state, can't it
> > do something like the following?
> >
> > - Trigger kick from update_idle(cpu, true) and remember that the CPU is in
> > the polling state.
> >
> > - Keep kicking from ops.dispatch() until polling state is cleared.
> >
> > As what kick() guarnatees is at least one dispatch event after kicking, this
> > is guaranteed to be correct and the control flow, while a bit more
> > complicated, makes sense - it triggers dispatch on idle transition and keeps
> > dispatching in the idle state.
> >
> > What do you think?
>
> That seems to work in theory, I'll run some tests to confirm that it
> also works in practice. :)
>
> It looks definitely nicer than triggering multiple ops.update_idle()
> from the kernel and we can maintain the proper semantic of triggering
> update_idle() only on actual idle state changes.
For the record, this seems to be working for now. Here is the
implementation of the idea proposed by Tejun:
https://github.com/sched-ext/scx/commit/40ccca8cbef8fc73e16bfb789c7565326b3cca62
Therefore, we can ignore the kernel patch.
Thanks for the help on this!
-Andrea