Re: sched/fair: Kernel panics in pick_next_entity

From: Vishal Chourasia
Date: Fri Oct 04 2024 - 03:18:39 EST


On Thu, Oct 03, 2024 at 11:31:06AM +0200, Mike Galbraith wrote:
> On Thu, 2024-10-03 at 06:41 +0200, Mike Galbraith wrote:
> > On Wed, 2024-10-02 at 15:31 -0700, Benjamin Segall wrote:
>
> > > 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.
>
> Probable not worth any churn or effort, but it is an option.
>
> sched: Clean up sched_delayed handling in unthrottle_cfs_rq()
>
> requeue_delayed_entity() achieves and documents in one line what a less
> clear preparatory dequeue facilitates over several, so use it instead,
> and remove the superfluous comment.
>
> Signed-off-by: Mike Galbraith <efault@xxxxxx>
Hi Mike, thanks for the patch!

I didn't see any warnings or kernel panics in my setup.

Tested-by: Vishal Chourasia <vishalc@xxxxxxxxxxxxx>
> ---
> kernel/sched/fair.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6058,12 +6058,9 @@ void unthrottle_cfs_rq(struct cfs_rq *cf
> for_each_sched_entity(se) {
> struct cfs_rq *qcfs_rq = cfs_rq_of(se);
>
> - /* 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)
> + if (se->sched_delayed)
> + requeue_delayed_entity(se);
> + if (se->on_rq)
> break;
> enqueue_entity(qcfs_rq, se, ENQUEUE_WAKEUP);
>
>