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/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

authored by

Peter Zijlstra and committed by
Ingo Molnar
47efe2dd 95a01552

+14
+13
kernel/sched/core.c
··· 10782 10782 10783 10783 *ctx = (struct sched_change_ctx){ 10784 10784 .p = p, 10785 + .class = p->sched_class, 10785 10786 .flags = flags, 10786 10787 .queued = task_on_rq_queued(p), 10787 10788 .running = task_current_donor(rq, p), ··· 10813 10812 10814 10813 lockdep_assert_rq_held(rq); 10815 10814 10815 + /* 10816 + * Changing class without *QUEUE_CLASS is bad. 10817 + */ 10818 + WARN_ON_ONCE(p->sched_class != ctx->class && !(ctx->flags & ENQUEUE_CLASS)); 10819 + 10816 10820 if ((ctx->flags & ENQUEUE_CLASS) && p->sched_class->switching_to) 10817 10821 p->sched_class->switching_to(rq, p); 10818 10822 ··· 10829 10823 if (ctx->flags & ENQUEUE_CLASS) { 10830 10824 if (p->sched_class->switched_to) 10831 10825 p->sched_class->switched_to(rq, p); 10826 + 10827 + /* 10828 + * If this was a degradation in class someone should have set 10829 + * need_resched by now. 10830 + */ 10831 + WARN_ON_ONCE(sched_class_above(ctx->class, p->sched_class) && 10832 + !test_tsk_need_resched(p)); 10832 10833 } else { 10833 10834 p->sched_class->prio_changed(rq, p, ctx->prio); 10834 10835 }
+1
kernel/sched/sched.h
··· 3968 3968 struct sched_change_ctx { 3969 3969 u64 prio; 3970 3970 struct task_struct *p; 3971 + const struct sched_class *class; 3971 3972 int flags; 3972 3973 bool queued; 3973 3974 bool running;