Re: [PATCH v2 12/12] sched: Remove sched_class::balance()

From: Tejun Heo

Date: Wed Nov 11 2026 - 06:19:49 EST


Hello,

On Sat, Nov 07, 2026 at 12:59:25PM +0100, Peter Zijlstra wrote:
> static struct task_struct *pick_task_rt(struct rq *rq, struct rq_flags *rf)
> {
> - struct task_struct *p;
> + rq_modified_begin(rq, &rt_sched_class);
> + balance_rt(rq, rf);
> + if (rq_modified_above(rq, &rt_sched_class))
> + return RETRY_TASK;

This exposes an underlying problem on the DL side. rq->next_class is
raised only by wakeup_preempt(), but dl_server_start(), dl_task_timer()
and dl_server_timer() enqueue a DL entity and open-code resched_curr()
without going through it. prev_balance() ran before any class was
picked, so it didn't matter. Now, pick_task_dl() has already returned
NULL when balance_rt() drops the lock, and rq_modified_above() is the
only thing which can notice a DL entity queued in the meantime:

CPU0 RT task blocks, pick_task_dl() returns NULL
pick_task_rt(), balance_rt() drops the rq lock
CPU1 wakes a fair task onto CPU0, dl_server_start()
CPU0 relocks, rq_modified_above() is false
picks an RT task with the fair server queued

resched_curr() doesn't help as __schedule() clears it on prev after the
pick. I can trigger this with NO_RT_PUSH_IPI and a delay added in the
lock drop. With RT_PUSH_IPI, pull_rt_task() doesn't drop the lock.

Maybe the DL sites should raise rq->next_class where they enqueue and
resched, so that they behave the same as regular wakeups?

Thanks.

--
tejun