From: Juri Lelli <juri.lelli@redhat.com> Date: 2022-07-13 07:50:52
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")
Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
---
kernel/sched/deadline.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Peter Zijlstra <peterz@infradead.org> Date: 2022-07-13 11:46:34
On Wed, Jul 13, 2022 at 09:50:14AM +0200, Juri Lelli wrote:
quoted hunk
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")
Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
---
kernel/sched/deadline.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Juri Lelli <juri.lelli@redhat.com> Date: 2022-07-13 12:58:18
On 13/07/22 13:46, Peter Zijlstra wrote:
On Wed, Jul 13, 2022 at 09:50:14AM +0200, Juri Lelli wrote:
quoted
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")
Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
---
kernel/sched/deadline.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Srivatsa S. Bhat <hidden> Date: 2022-07-13 21:31:35
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?
Thank you!
From: Juri Lelli <juri.lelli@redhat.com> Date: 2022-07-14 07:28:19
Hi,
On 13/07/22 14:31, Srivatsa S. Bhat wrote:
Hi Juri,
On 7/13/22 12:50 AM, Juri Lelli wrote:
quoted
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
On 14-Jul-2022, at 12:58 PM, Juri Lelli [off-list ref] wrote:
⚠ External Email
Hi,
On 13/07/22 14:31, Srivatsa S. Bhat wrote:
quoted
Hi Juri,
On 7/13/22 12:50 AM, Juri Lelli wrote:
quoted
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
Thanks for testing!
However, it looks like 4.19-rt is at least missing commit 46fcc4b00c3cc
("sched/deadline: Fix stale throttling on de-/boosted tasks") and commit
2279f540ea7d0 ("sched/deadline: Fix priority inheritance with multiple
scheduling classes") that might be playing also a role here.
Best,
Juri
Thanks for testing!
However, it looks like 4.19-rt is at least missing commit 46fcc4b00c3cc
("sched/deadline: Fix stale throttling on de-/boosted tasks") and commit
2279f540ea7d0 ("sched/deadline: Fix priority inheritance with multiple
scheduling classes") that might be playing also a role here.
Best,
Juri
Hi Juri,
Actually, while testing I already included below commits in 4.19-rt :
feff2e65efd8d84cf831668e182b2ce73c604bbb (sched/deadline: Unthrottle PI boosted threads while
enqueuing)
46fcc4b00c3cca8adb9b7c9afdd499f64e427135 (sched/deadline: Fix stale throttling on de-/boosted tasks)
2279f540ea7d05f22d2f0c4224319330228586bc (sched/deadline: Fix priority inheritance with multiple)
0e3872499de1a1230cef5221607d71aa09264bd5 (kernel/sched: Remove dl_boosted flag comment)
Thanks,
Ankit
From: Juri Lelli <juri.lelli@redhat.com> Date: 2022-07-18 13:01:37
On 18/07/22 07:46, Ankit Jain wrote:
...
Hi Juri,
Actually, while testing I already included below commits in 4.19-rt :
feff2e65efd8d84cf831668e182b2ce73c604bbb (sched/deadline: Unthrottle PI boosted threads while
enqueuing)
46fcc4b00c3cca8adb9b7c9afdd499f64e427135 (sched/deadline: Fix stale throttling on de-/boosted tasks)
2279f540ea7d05f22d2f0c4224319330228586bc (sched/deadline: Fix priority inheritance with multiple)
0e3872499de1a1230cef5221607d71aa09264bd5 (kernel/sched: Remove dl_boosted flag comment)
Interesting.
Is the workload you are using to test this easily reproducible? I'd like
to try that out on my end to check if I see the same (of course the
issue I was working on goes away with my fix :).
Best,
Juri
On 18-Jul-2022, at 6:31 PM, Juri Lelli [off-list ref] wrote:
⚠ External Email
On 18/07/22 07:46, Ankit Jain wrote:
...
quoted
Hi Juri,
Actually, while testing I already included below commits in 4.19-rt :
feff2e65efd8d84cf831668e182b2ce73c604bbb (sched/deadline: Unthrottle PI boosted threads while
enqueuing)
46fcc4b00c3cca8adb9b7c9afdd499f64e427135 (sched/deadline: Fix stale throttling on de-/boosted tasks)
2279f540ea7d05f22d2f0c4224319330228586bc (sched/deadline: Fix priority inheritance with multiple)
0e3872499de1a1230cef5221607d71aa09264bd5 (kernel/sched: Remove dl_boosted flag comment)
Interesting.
Is the workload you are using to test this easily reproducible? I'd like
to try that out on my end to check if I see the same (of course the
issue I was working on goes away with my fix :).
Best,
Juri
Hi Juri,
The test with which i am able to hit the issue is as follows:
• Schedule SCHED_FIFO/55 (sched_priority = 55) tasks running infinite loop on all isolated cores.
• spwan 30-40 docker containers in loop (docker load , docker run)
• Immediately after that schedule SCHED_FIFO/55 (sched_priority = 55) tasks running infinite loop on all isolated cores again.
• BUG_ON gets hit almost every time.
System config as follows:
• 4.19-rt kernel
• 40 cpu (0-1 housekeeping, 2-39 isol cpus)
• stalld-1.3.0 with the fixes from latest version (for task starvation avoidance), "tuned" with real-time profile
Thanks.
From: Juri Lelli <juri.lelli@redhat.com> Date: 2022-07-19 07:19:23
On 19/07/22 05:30, Ankit Jain wrote:
quoted
On 18-Jul-2022, at 6:31 PM, Juri Lelli [off-list ref] wrote:
⚠ External Email
On 18/07/22 07:46, Ankit Jain wrote:
...
quoted
Hi Juri,
Actually, while testing I already included below commits in 4.19-rt :
feff2e65efd8d84cf831668e182b2ce73c604bbb (sched/deadline: Unthrottle PI boosted threads while
enqueuing)
46fcc4b00c3cca8adb9b7c9afdd499f64e427135 (sched/deadline: Fix stale throttling on de-/boosted tasks)
2279f540ea7d05f22d2f0c4224319330228586bc (sched/deadline: Fix priority inheritance with multiple)
0e3872499de1a1230cef5221607d71aa09264bd5 (kernel/sched: Remove dl_boosted flag comment)
Interesting.
Is the workload you are using to test this easily reproducible? I'd like
to try that out on my end to check if I see the same (of course the
issue I was working on goes away with my fix :).
Best,
Juri
Hi Juri,
The test with which i am able to hit the issue is as follows:
• Schedule SCHED_FIFO/55 (sched_priority = 55) tasks running infinite loop on all isolated cores.
• spwan 30-40 docker containers in loop (docker load , docker run)
• Immediately after that schedule SCHED_FIFO/55 (sched_priority = 55) tasks running infinite loop on all isolated cores again.
• BUG_ON gets hit almost every time.
System config as follows:
• 4.19-rt kernel
• 40 cpu (0-1 housekeeping, 2-39 isol cpus)
• stalld-1.3.0 with the fixes from latest version (for task starvation avoidance), "tuned" with real-time profile
Thanks for the details. Yeah, I should be able to set this up on my end.
It might just take a bit though, as I have some pto planned coming up.
But, I'll get to it eventually.
Thanks again,
Juri