Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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@linaro.org>
Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251216141725.GW3707837@noisy.programming.kicks-ass.net

+17 -16
+17 -16
kernel/sched/core.c
··· 10833 10833 if (p->sched_class->switched_to) 10834 10834 p->sched_class->switched_to(rq, p); 10835 10835 10836 - /* 10837 - * If this was a class promotion; let the old class know it 10838 - * got preempted. Note that none of the switch*_from() methods 10839 - * know the new class and none of the switch*_to() methods 10840 - * know the old class. 10841 - */ 10842 - if (ctx->running && sched_class_above(p->sched_class, ctx->class)) { 10843 - rq->next_class->wakeup_preempt(rq, p, 0); 10844 - rq->next_class = p->sched_class; 10836 + if (ctx->running) { 10837 + /* 10838 + * If this was a class promotion; let the old class 10839 + * know it got preempted. Note that none of the 10840 + * switch*_from() methods know the new class and none 10841 + * of the switch*_to() methods know the old class. 10842 + */ 10843 + if (sched_class_above(p->sched_class, ctx->class)) { 10844 + rq->next_class->wakeup_preempt(rq, p, 0); 10845 + rq->next_class = p->sched_class; 10846 + } 10847 + /* 10848 + * If this was a degradation in class; make sure to 10849 + * reschedule. 10850 + */ 10851 + if (sched_class_above(ctx->class, p->sched_class)) 10852 + resched_curr(rq); 10845 10853 } 10846 - 10847 - /* 10848 - * If this was a degradation in class someone should have set 10849 - * need_resched by now. 10850 - */ 10851 - WARN_ON_ONCE(sched_class_above(ctx->class, p->sched_class) && 10852 - !test_tsk_need_resched(p)); 10853 10854 } else { 10854 10855 p->sched_class->prio_changed(rq, p, ctx->prio); 10855 10856 }