Re: [PATCH v2] sched/rt: Do not account migrate-disabled tasks as pushable
From: Mel Gorman
Date: Thu Nov 12 2026 - 20:30:37 EST
On Thu, Nov 12, 2026 at 04:31:20PM +0100, Peter Zijlstra wrote:
> On Thu, Nov 12, 2026 at 02:17:29PM +0000, Mel Gorman wrote:
>
> > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> > index 1535046a23ff..bb640278d30e 100644
> > --- a/kernel/sched/rt.c
> > +++ b/kernel/sched/rt.c
> > @@ -396,6 +396,13 @@ 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)
> > + return;
> > +#ifdef HAVE_RT_PUSH_IPI
> > + if (sched_feat(RT_PUSH_IPI) && is_migration_disabled(p))
> > + return;
> > +#endif
>
> Is there any down-side from unconditionally having that
> is_migration_disabled() test there?
>
It's a simple check of p->migration_disabled so compute-wise it's simple. It
might incur a cache miss that may not be already fetched if nothing else
prior contended on a spin lock. On !PREEMPT_RT, the static branch should
hide it by default so it's a PREEMPT_RT-specific hazard.
> > 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 +1455,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)
> > + if (!task_current(rq, p))
> > enqueue_pushable_task(rq, p);
> > }
> >
> > @@ -1746,7 +1753,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)
> > + if (on_rt_rq(&p->rt))
> > enqueue_pushable_task(rq, p);
> > }
>
> And can I ask you to do the same to DL ? Where possible we try and keep
> them in-sync.
I can move the "p->nr_cpus_allowed > 1" check and I think that's what you
are referring to.
I cannot add the is_migration_disabled() to match as deadline does not
have a mechanism equivalent to RT_PUSH_IPI. Adding migration_disabled
check anyway damages pull_dl_task in a way that is difficult to detect
e.g. if a runqueue has multiple runnable tasks with earlier deadlines and 1
migrate-disabled then the 2 tasks can be left competing (side-effect benefit
but still). Worse, sometimes adding it would work better -- a running task
with an earlier deadline but sufficient time to complete is left alone if
the rq is shared with a migrate-disabled task and hidden as a push candidate.
V3 will follow shortly.
--
Mel Gorman
SUSE Labs