[PATCH 4/7] sched/rt: Add early exit on balance path

From: Peter Zijlstra

Date: Fri Aug 28 2026 - 06:42:17 EST


Add/make consistent an early exit on the balance_{rt,dl}() path. When there are
no pushable tasks, there is no point in taking the rq lock and all that jazz.

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
kernel/sched/deadline.c | 10 +++-------
kernel/sched/rt.c | 3 +++
2 files changed, 6 insertions(+), 7 deletions(-)

--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -3250,17 +3250,13 @@ static void pull_dl_task(struct rq *this
src_rq->dl.earliest_dl.next))
continue;

+ if (!has_pushable_dl_tasks(src_rq))
+ continue;
+
/* Might drop this_rq->lock */
push_task = NULL;
double_lock_balance(this_rq, src_rq);

- /*
- * If there are no more pullable tasks on the
- * rq, we're done with it.
- */
- if (src_rq->dl.dl_nr_running <= 1)
- goto skip;
-
p = pick_earliest_pushable_dl_task(src_rq, this_cpu);

/*
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2303,6 +2303,9 @@ static void pull_rt_task(struct rq *this
this_rq->rt.highest_prio.curr)
continue;

+ if (!has_pushable_tasks(src_rq))
+ continue;
+
/*
* We can potentially drop this_rq's lock in
* double_lock_balance, and another CPU could