[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <176596899373.510.17191516261088315233.tip-bot2@tip-bot2>
Date: Wed, 17 Dec 2025 10:56:33 -0000
From: "tip-bot2 for Peter Zijlstra" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Naresh Kamboju <naresh.kamboju@...aro.org>,
Linux Kernel Functional Testing <lkft@...aro.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: sched/core] sched: Fix faulty assertion in sched_change_end()
The following commit has been merged into the sched/core branch of tip:
Commit-ID: 1862d8e264def8425d682f1177e22f9fe7d947ea
Gitweb: https://git.kernel.org/tip/1862d8e264def8425d682f1177e22f9fe7d947ea
Author: Peter Zijlstra <peterz@...radead.org>
AuthorDate: Wed, 17 Dec 2025 11:24:11 +01:00
Committer: Peter Zijlstra <peterz@...radead.org>
CommitterDate: Wed, 17 Dec 2025 11:41:18 +01:00
sched: Fix faulty assertion in sched_change_end()
Commit 47efe2ddccb1f ("sched/core: Add assertions to QUEUE_CLASS") added an
assert to sched_change_end() verifying that a class demotion would result in a
reschedule.
As it turns out; rt_mutex_setprio() does not force a resched on class
demontion. Furthermore, this is only relevant to running tasks.
Change the warning into a reschedule and make sure to only do so for running
tasks.
Fixes: 47efe2ddccb1f ("sched/core: Add assertions to QUEUE_CLASS")
Reported-by: Naresh Kamboju <naresh.kamboju@...aro.org>
Tested-by: Linux Kernel Functional Testing <lkft@...aro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Link: https://patch.msgid.link/20251216141725.GW3707837@noisy.programming.kicks-ass.net
---
kernel/sched/core.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7d0a862..5b17d8e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -10833,23 +10833,24 @@ void sched_change_end(struct sched_change_ctx *ctx)
if (p->sched_class->switched_to)
p->sched_class->switched_to(rq, p);
- /*
- * If this was a class promotion; let the old class know it
- * got preempted. Note that none of the switch*_from() methods
- * know the new class and none of the switch*_to() methods
- * know the old class.
- */
- if (ctx->running && sched_class_above(p->sched_class, ctx->class)) {
- rq->next_class->wakeup_preempt(rq, p, 0);
- rq->next_class = p->sched_class;
+ if (ctx->running) {
+ /*
+ * If this was a class promotion; let the old class
+ * know it got preempted. Note that none of the
+ * switch*_from() methods know the new class and none
+ * of the switch*_to() methods know the old class.
+ */
+ if (sched_class_above(p->sched_class, ctx->class)) {
+ rq->next_class->wakeup_preempt(rq, p, 0);
+ rq->next_class = p->sched_class;
+ }
+ /*
+ * If this was a degradation in class; make sure to
+ * reschedule.
+ */
+ if (sched_class_above(ctx->class, p->sched_class))
+ resched_curr(rq);
}
-
- /*
- * If this was a degradation in class someone should have set
- * need_resched by now.
- */
- WARN_ON_ONCE(sched_class_above(ctx->class, p->sched_class) &&
- !test_tsk_need_resched(p));
} else {
p->sched_class->prio_changed(rq, p, ctx->prio);
}
Powered by blists - more mailing lists