Re: sched/fair: Kernel panics in pick_next_entity

From: Mike Galbraith
Date: Thu Oct 03 2024 - 00:42:05 EST


On Wed, 2024-10-02 at 15:31 -0700, Benjamin Segall wrote:
> Mike Galbraith <efault@xxxxxx> writes:
> >
> > ---
> >  kernel/sched/fair.c |    9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -6058,10 +6058,13 @@ void unthrottle_cfs_rq(struct cfs_rq *cf
> >         for_each_sched_entity(se) {
> >                 struct cfs_rq *qcfs_rq = cfs_rq_of(se);
> >
> > -               if (se->on_rq) {
> > -                       SCHED_WARN_ON(se->sched_delayed);
> > +               /* Handle any unfinished DELAY_DEQUEUE business first. */
> > +               if (se->sched_delayed) {
> > +                       int flags = DEQUEUE_SLEEP | DEQUEUE_DELAYED;
> > +
> > +                       dequeue_entity(qcfs_rq, se, flags);
> > +               } else if (se->on_rq)
> >                         break;
> > -               }
> >                 enqueue_entity(qcfs_rq, se, ENQUEUE_WAKEUP);
> >
> >                 if (cfs_rq_is_idle(group_cfs_rq(se)))
>
> Yeah, if we can wind up here to hit that warning, then we need to get it
> out of delay state, not just leave it. Whether dequeue_entity +
> enqueue_entity is better or worse than requeue_delayed_entity (+ break), I really
> don't know.

Hm, I'd say requeue_delayed_entity() not only fits better, it using
less lines gives it an extra brownie point.

-Mike