Re: [PATCH 3/6 v3] sched/eevdf: Update slice protection even when resched is already set

From: Peter Zijlstra

Date: Fri Jun 26 2026 - 03:49:31 EST


On Fri, Jun 26, 2026 at 09:21:28AM +0200, Peter Zijlstra wrote:
> On Wed, Jun 24, 2026 at 05:12:26PM +0200, Vincent Guittot wrote:
> > Even if resched is already set, we might want to update or even cancel
> > the slice protection and ensure that the newly waking task will be the
> > next one to run.
> >
> > Signed-off-by: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
> > Tested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
> > ---
> > kernel/sched/fair.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 8639086e5d9e..854f3a9f1d80 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -9804,7 +9804,7 @@ static void wakeup_preempt_fair(struct rq *rq, struct task_struct *p, int wake_f
> > * prevents us from potentially nominating it as a false LAST_BUDDY
> > * below.
> > */
> > - if (test_tsk_need_resched(rq->curr))
> > + if (!sched_feat(PREEMPT_SHORT) && test_tsk_need_resched(rq->curr))
> > return;
> >
> > if (!sched_feat(WAKEUP_PREEMPTION))
>
> This one is leading to boot splats for me -- let me try and figure out
> why.

Bah!


Subject: sched/core: Fix inter-class wakeup_preempt()
From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Date: Fri Jun 26 09:36:52 CEST 2026

The way wakeup_preempt() works since commit 704069649b5b ("sched/core: Rework
sched_class::wakeup_preempt() and rq_modified_*()") is that it will call
rq->next_class->wakeup_preempt(rq, p) when p is of an equal or higher class,
and raise ->next_class when higher.

This means that:

running idle task

wakeup fair-A
(next_class == idle)
if (sched_class_above(fair, idle)) {
wakeup_preempt_idle(fair-A);
resched_curr(rq);
next_class = fair;
}

wakeup fair-B
(next_class == fair)
if (fair == fair)
wakeup_preempt_fair(fair-B);
(but current is idle)

All wakeup_preempt_$class() methods, except for wakeup_preempt_scx() (for whoem
this was build) ignore cross-class wakeups by testing if @p is of the right
class, but per the above case, it also should check current.

This is mostly harmless in the current form, but will lead to trouble with
later patches.

Fixes: 704069649b5b ("sched/core: Rework sched_class::wakeup_preempt() and rq_modified_*()")
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
kernel/sched/deadline.c | 6 ++++--
kernel/sched/fair.c | 3 ++-
kernel/sched/rt.c | 3 ++-
3 files changed, 8 insertions(+), 4 deletions(-)

--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2733,15 +2733,17 @@ static int balance_dl(struct rq *rq, str
*/
static void wakeup_preempt_dl(struct rq *rq, struct task_struct *p, int flags)
{
+ struct task_struct *donor = rq->donor;
/*
* Can only get preempted by stop-class, and those should be
* few and short lived, doesn't really make sense to push
* anything away for that.
*/
- if (p->sched_class != &dl_sched_class)
+ if (p->sched_class != &dl_sched_class ||
+ donor->sched_class != &dl_sched_class)
return;

- if (dl_entity_preempt(&p->dl, &rq->donor->dl)) {
+ if (dl_entity_preempt(&p->dl, &donor->dl)) {
resched_curr(rq);
return;
}
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9778,7 +9778,8 @@ static void wakeup_preempt_fair(struct r
/*
* XXX Getting preempted by higher class, try and find idle CPU?
*/
- if (p->sched_class != &fair_sched_class)
+ if (p->sched_class != &fair_sched_class ||
+ donor->sched_class != &fair_sched_class)
return;

if (unlikely(se == pse))
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1629,7 +1629,8 @@ static void wakeup_preempt_rt(struct rq
/*
* XXX If we're preempted by DL, queue a push?
*/
- if (p->sched_class != &rt_sched_class)
+ if (p->sched_class != &rt_sched_class ||
+ donor->sched_class != &rt_sched_class)
return;

if (p->prio < donor->prio) {