[PATCH 2/3] sched/rt: Check eligibility of pushable task in one place

From: Mel Gorman

Date: Tue Nov 10 2026 - 18:24:21 EST


Two callers of enqueue_pushable_task() perform the same checks, move them
to one place to mitigate the risk of the checks made out of sync and in
preparation for the next patch.

No functional change intended.

Signed-off-by: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx>
---
kernel/sched/rt.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 2587ef92efc3..cc77683f4897 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -396,6 +396,9 @@ static inline void rt_queue_pull_task(struct rq *rq)

static void enqueue_pushable_task(struct rq *rq, struct task_struct *p)
{
+ if (p->nr_cpus_allowed <= 1 || is_migration_disabled(p))
+ return;
+
plist_del(&p->pushable_tasks, &rq->rt.pushable_tasks);
plist_node_init(&p->pushable_tasks, p->prio);
plist_add(&p->pushable_tasks, &rq->rt.pushable_tasks);
@@ -1448,7 +1451,7 @@ enqueue_task_rt(struct rq *rq, struct task_struct *p, int flags)
if (task_is_blocked(p))
return;

- if (!task_current(rq, p) && p->nr_cpus_allowed > 1 && !is_migration_disabled(p))
+ if (!task_current(rq, p))
enqueue_pushable_task(rq, p);
}

@@ -1746,7 +1749,7 @@ static void put_prev_task_rt(struct rq *rq, struct task_struct *p, struct task_s
* The previous task needs to be made eligible for pushing
* if it is still active
*/
- if (on_rt_rq(&p->rt) && p->nr_cpus_allowed > 1 && !is_migration_disabled(p))
+ if (on_rt_rq(&p->rt))
enqueue_pushable_task(rq, p);
}

--
2.55.0