[PATCH 2/2] sched/rt: Restore pinned candidates for PUSH_IPI balancing

From: Josh Lafleur via B4 Relay

Date: Mon Nov 23 2026 - 14:22:33 EST


From: "Josh Lafleur (Zipline)" <josh.lafleur@xxxxxxxxxxx>

Commit a7c81556ec4d ("sched: Fix migrate_disable() vs rt/dl
balancing") added a PUSH_IPI fallback for a migrate-disabled RT
candidate. It runs the stopper to move the running task so that the
pinned task can run on its current CPU.

Commit dae5c0292080 ("sched/rt,dl: Skip migrate-disabled tasks when
picking a push candidate") made the RT picker skip pinned candidates.
This avoids futile ordinary pushes, but also prevents the push-IPI
path from reaching that fallback.

Select migrate-disabled candidates on the PUSH_IPI path, while
continuing to skip them on ordinary pushes. An ordinary push can
therefore still reach a movable task behind a pinned one. Use the
same selection mode when retrying after a failed destination search;
the head recheck for ordinary candidates continues to skip pinned
tasks.

The preceding patch allows the stopper target to pass the head
recheck after the source rq lock is reacquired.

Fixes: dae5c0292080 ("sched/rt,dl: Skip migrate-disabled tasks when picking a push candidate")
---
kernel/sched/rt.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 54a6533cffe07..bb0d125889bd1 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1866,7 +1866,7 @@ static int find_lowest_rq(struct task_struct *task)
return -1;
}

-static struct task_struct *pick_next_pushable_task(struct rq *rq)
+static struct task_struct *pick_next_pushable_task(struct rq *rq, bool pull)
{
struct plist_head *head = &rq->rt.pushable_tasks;
struct task_struct *i, *p = NULL;
@@ -1875,8 +1875,9 @@ static struct task_struct *pick_next_pushable_task(struct rq *rq)
return NULL;

plist_for_each_entry(i, head, pushable_tasks) {
- /* skip tasks that cannot be migrated */
- if (!task_on_cpu(rq, i) && !is_migration_disabled(i)) {
+ /* Only the push-IPI path can push the current task instead. */
+ if (!task_on_cpu(rq, i) &&
+ (pull || !is_migration_disabled(i))) {
p = i;
break;
}
@@ -1941,7 +1942,7 @@ static struct rq *find_lock_lowest_rq(struct task_struct *task, struct rq *rq)
*/
if (unlikely(is_migration_disabled(task) ||
!cpumask_test_cpu(lowest_rq->cpu, &task->cpus_mask) ||
- (task != pick_next_pushable_task(rq) &&
+ (task != pick_next_pushable_task(rq, false) &&
!stopper_push))) {

double_unlock_balance(rq, lowest_rq);
@@ -1976,7 +1977,7 @@ static int push_rt_task(struct rq *rq, bool pull)
if (!rq->rt.overloaded)
return 0;

- next_task = pick_next_pushable_task(rq);
+ next_task = pick_next_pushable_task(rq, pull);
if (!next_task)
return 0;

@@ -2051,7 +2052,7 @@ static int push_rt_task(struct rq *rq, bool pull)
* run-queue and is also still the next task eligible for
* pushing.
*/
- task = pick_next_pushable_task(rq);
+ task = pick_next_pushable_task(rq, pull);
if (task == next_task) {
/*
* The task hasn't migrated, and is still the next

--
2.53.0