Re: [PATCH] sched/deadline: Fix BUG_ON condition for deboosted tasks

From: Juri Lelli
Date: Thu Jul 14 2022 - 03:28:19 EST


Hi,

On 13/07/22 14:31, Srivatsa S. Bhat wrote:
>
> Hi Juri,
>
> On 7/13/22 12:50 AM, Juri Lelli wrote:
> > Tasks the are being deboosted from SCHED_DEADLINE might enter
> > enqueue_task_dl() one last time and hit an erroneous BUG_ON condition:
> > since they are not boosted anymore, the if (is_dl_boosted()) branch is
> > not taken, but the else if (!dl_prio) is and inside this one we
> > BUG_ON(!is_dl_boosted), which is of course false (BUG_ON triggered)
> > otherwise we had entered the if branch above. Long story short, the
> > current condition doesn't make sense and always leads to triggering of a
> > BUG.
> >
> > Fix this by only checking enqueue flags, properly: ENQUEUE_REPLENISH has
> > to be present, but additional flags are not a problem.
> >
> > Fixes: 2279f540ea7d ("sched/deadline: Fix priority inheritance with multiple scheduling classes")
>
> It looks like this problem goes further back than the above commit
> (which was merged in v5.10).
>
> Even the oldest LTS kernel (4.9) has code like this:
>
> if (... && p->dl.dl_boosted && ...)) {
> /* code */
>
> } else if (!dl_prio(p->normal_prio)) {
>
> BUG_ON(!p->dl.dl_boosted || flags != ENQUEUE_REPLENISH);
> return;
> }
>
> And we have observed crashes in the 4.19 kernel series too (CC'ed
> Ankit Jain and Him Kalyan who have reproduced this issue).
>
> I believe commit 64be6f1f5f71 ("sched/deadline: Don't replenish from a
> !SCHED_DEADLINE entity") introduced the problem, which dates back to
> v3.18.
>
> Would you mind updating the Fixes: tag and adding a CC: stable tag as
> well, when you respin the patch, please?

I think you are right. Will do.

Thanks for taking a look!

Best,
Juri