All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] sched/deadline: Fix BUG_ON condition for deboosted tasks
@ 2022-07-14 15:19 Juri Lelli
  2022-07-21  8:44 ` [tip: sched/urgent] " tip-bot2 for Juri Lelli
  0 siblings, 1 reply; 2+ messages in thread
From: Juri Lelli @ 2022-07-14 15:19 UTC (permalink / raw)
  To: LKML, linux-rt-users
  Cc: Srivatsa S. Bhat, Juri Lelli, stable, Ingo Molnar,
	Peter Zijlstra, Vincent Guittot, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Mel Gorman,
	Daniel Bristot de Oliveira, Valentin Schneider

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: 64be6f1f5f71 ("sched/deadline: Don't replenish from a !SCHED_DEADLINE entity")
Cc: stable@vger.kernel.org
Signed-off-by: Juri Lelli <juri.lelli@redhat.com>

---
v1->v2
 - Make detection of faulty condition less fatal [Peter Zijlstra]
 - Cc stable and update fixes tag [Srivatsa S. Bhat]
---
 kernel/sched/deadline.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 5867e186c39a..0ab79d819a0d 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1703,7 +1703,10 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags)
 		 * the throttle.
 		 */
 		p->dl.dl_throttled = 0;
-		BUG_ON(!is_dl_boosted(&p->dl) || flags != ENQUEUE_REPLENISH);
+		if (!(flags & ENQUEUE_REPLENISH))
+			printk_deferred_once("sched: DL de-boosted task PID %d: REPLENISH flag missing\n",
+					     task_pid_nr(p));
+
 		return;
 	}
 
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip: sched/urgent] sched/deadline: Fix BUG_ON condition for deboosted tasks
  2022-07-14 15:19 [PATCH v2] sched/deadline: Fix BUG_ON condition for deboosted tasks Juri Lelli
@ 2022-07-21  8:44 ` tip-bot2 for Juri Lelli
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Juri Lelli @ 2022-07-21  8:44 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Juri Lelli, Peter Zijlstra (Intel), stable, x86, linux-kernel

The following commit has been merged into the sched/urgent branch of tip:

Commit-ID:     ddfc710395cccc61247348df9eb18ea50321cbed
Gitweb:        https://git.kernel.org/tip/ddfc710395cccc61247348df9eb18ea50321cbed
Author:        Juri Lelli <juri.lelli@redhat.com>
AuthorDate:    Thu, 14 Jul 2022 17:19:08 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 21 Jul 2022 10:35:28 +02:00

sched/deadline: Fix BUG_ON condition for deboosted tasks

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: 64be6f1f5f71 ("sched/deadline: Don't replenish from a !SCHED_DEADLINE entity")
Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20220714151908.533052-1-juri.lelli@redhat.com
---
 kernel/sched/deadline.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index b515296..7bf5612 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1701,7 +1701,10 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags)
 		 * the throttle.
 		 */
 		p->dl.dl_throttled = 0;
-		BUG_ON(!is_dl_boosted(&p->dl) || flags != ENQUEUE_REPLENISH);
+		if (!(flags & ENQUEUE_REPLENISH))
+			printk_deferred_once("sched: DL de-boosted task PID %d: REPLENISH flag missing\n",
+					     task_pid_nr(p));
+
 		return;
 	}
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-21  8:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 15:19 [PATCH v2] sched/deadline: Fix BUG_ON condition for deboosted tasks Juri Lelli
2022-07-21  8:44 ` [tip: sched/urgent] " tip-bot2 for Juri Lelli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.