Re: [RFC][PATCH 1/3] sched: Detect per-class runqueue changes
From: Juri Lelli
Date: Tue Oct 07 2025 - 06:26:38 EST
On 07/10/25 12:16, Peter Zijlstra wrote:
> On Tue, Oct 07, 2025 at 12:08:03PM +0200, Juri Lelli wrote:
> > Hi Peter,
> >
> > On 06/10/25 12:46, Peter Zijlstra wrote:
> > > Have enqueue/dequeue set a per-class bit in rq->queue_mask. This then
> > > enables easy tracking of which runqueues are modified over a
> > > lock-break.
> > >
> > > Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> > > ---
> >
> > Nice.
> >
> > > @@ -12887,8 +12888,8 @@ static int sched_balance_newidle(struct
> > > if (this_rq->cfs.h_nr_queued && !pulled_task)
> > > pulled_task = 1;
> > >
> > > - /* Is there a task of a high priority class? */
> > > - if (this_rq->nr_running != this_rq->cfs.h_nr_queued)
> > > + /* If a higher prio class was modified, restart the pick */
> > > + if (this_rq->queue_mask & ~((fair_sched_class.queue_mask << 1)-1))
> > > pulled_task = -1;
> >
> > Does this however want a self-documenting inline helper or macro to make
> > it even more clear? If this is always going to be the only caller maybe
> > not so much.
>
> There's another one in patch 3. I suppose we can do that. Maybe
> something like:
>
> static inline bool rq_modified_above(struct rq *rq, struct sched_class *class)
> {
> unsigned int mask = class->queue_mask;
> return rq->queue_mask & ~((mask << 1) - 1);
> }
>
> This then writes the above like:
>
> if (rq_modified_above(this_rq, &fair_sched_class))
>
Yeah. Maybe also add a "check rq::queue_mask comment for additional
details" or something like this.
Thanks!
Juri