mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-22 00:14:52 -04:00
sched/core: Add assertions to QUEUE_CLASS
Add some checks to the sched_change pattern to validate assumptions around changing classes. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://patch.msgid.link/20251127154725.771691954@infradead.org
This commit is contained in:
committed by
Ingo Molnar
parent
95a0155224
commit
47efe2ddcc
@@ -10782,6 +10782,7 @@ struct sched_change_ctx *sched_change_begin(struct task_struct *p, unsigned int
|
|||||||
|
|
||||||
*ctx = (struct sched_change_ctx){
|
*ctx = (struct sched_change_ctx){
|
||||||
.p = p,
|
.p = p,
|
||||||
|
.class = p->sched_class,
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
.queued = task_on_rq_queued(p),
|
.queued = task_on_rq_queued(p),
|
||||||
.running = task_current_donor(rq, p),
|
.running = task_current_donor(rq, p),
|
||||||
@@ -10812,6 +10813,11 @@ void sched_change_end(struct sched_change_ctx *ctx)
|
|||||||
|
|
||||||
lockdep_assert_rq_held(rq);
|
lockdep_assert_rq_held(rq);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Changing class without *QUEUE_CLASS is bad.
|
||||||
|
*/
|
||||||
|
WARN_ON_ONCE(p->sched_class != ctx->class && !(ctx->flags & ENQUEUE_CLASS));
|
||||||
|
|
||||||
if ((ctx->flags & ENQUEUE_CLASS) && p->sched_class->switching_to)
|
if ((ctx->flags & ENQUEUE_CLASS) && p->sched_class->switching_to)
|
||||||
p->sched_class->switching_to(rq, p);
|
p->sched_class->switching_to(rq, p);
|
||||||
|
|
||||||
@@ -10823,6 +10829,13 @@ void sched_change_end(struct sched_change_ctx *ctx)
|
|||||||
if (ctx->flags & ENQUEUE_CLASS) {
|
if (ctx->flags & ENQUEUE_CLASS) {
|
||||||
if (p->sched_class->switched_to)
|
if (p->sched_class->switched_to)
|
||||||
p->sched_class->switched_to(rq, p);
|
p->sched_class->switched_to(rq, p);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 {
|
} else {
|
||||||
p->sched_class->prio_changed(rq, p, ctx->prio);
|
p->sched_class->prio_changed(rq, p, ctx->prio);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3968,6 +3968,7 @@ extern void balance_callbacks(struct rq *rq, struct balance_callback *head);
|
|||||||
struct sched_change_ctx {
|
struct sched_change_ctx {
|
||||||
u64 prio;
|
u64 prio;
|
||||||
struct task_struct *p;
|
struct task_struct *p;
|
||||||
|
const struct sched_class *class;
|
||||||
int flags;
|
int flags;
|
||||||
bool queued;
|
bool queued;
|
||||||
bool running;
|
bool running;
|
||||||
|
|||||||
Reference in New Issue
Block a user