Re: [PATCH v3] sched/rt: Do not account migrate-disabled tasks as pushable
From: Peter Zijlstra
Date: Tue Nov 17 2026 - 10:24:22 EST
On Tue, Nov 17, 2026 at 04:20:26PM +0100, Peter Zijlstra wrote:
> On Fri, Nov 13, 2026 at 04:06:55PM +0000, Mel Gorman wrote:
>
> > As above, the runqueue is still marked overloaded by enqueue_task_rt()
> > and put_prev_task_rt() even if the task is migrate-disabled. A
> > migrate-disabled task reaches the pushable list through enqueue_task_rt()
> > or put_prev_task_rt() when it is preempted, or when it wakes while
> > still migrate-disabled. Either path calls enqueue_pushable_task() to set
> > rq->rt.overloaded and rto_mask if unset. Once set, every pull from another
> > CPU that fires an IPI may only find migrate-disabled tasks rendering the IPI
> > useless for a condition that was detectable when placed on the pushable list.
> >
> > Stop adding migrate-disabled tasks to the pushable list if RT_PUSH_IPI is
> > enabled. This is not a heuristic as migrate-disabled tasks cannot move. Even
> > when migration is enabled, the rq still has no pushable candidates until the
> > task schedules. The !RT_PUSH_IPI behaviour is preserved and migrate-disabled
> > tasks are added to the pushable list. Without IPI, the alternative path in
> > pull_rt_task() must find runqueues with off-CPU migrate-disabled tasks. It
> > can then push the running task away allowing the migrate-disabled task
> > to run.
>
> Last time I either didn't notice, or I've gone dumb from staring at perf
> issues all day, but I'm not entirely sure I understand how we get here.
>
> Suppose:
>
> migrate_disable();
> ...
> schedule()
> migrate_disable_switch()
> // switches p->cpus_ptr and p->nr_cpus_allowed
> pick_next_task()
> p = class->pick_task();
> put_prev_set_next_task(rq, rq->donor, p);
> return p;
>
> So any task that ends up in put_prev_task_rt() wlll have passed through
> migrate_disable_switch(), which have updated nr_cpus_allowed.
>
> Or so my current thinking goes. You seeing this patch make a difference,
> seems to suggest I'm missing something, but I couldn't spot it in that
> wall of text.
Ah, is the sched_change pattern the clue? I'm thinking that RT might hit
that more than usual due to the PI path.
In that case we do indeed end up in put_prev_task() / set_next_task()
without going through schedule(). In that case the task would be on the
pushable list during the change, HOWEVER we should hold rq->lock (which
implies have IRQs disabled) over the entire thing, so again, I'm not
sure how this is then observable.
> Anyway, I'm still not sure why we can't just write:
>
> > 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
> > +
>
> if (p->nr_cpus_allowed <= 1 || is_migration_disabled(p))
> return;
>
> for both RT and DL. Sure, we might get an extra load, but is that really
> going to be noticable? Lots of scheduler code already looks at the
> migrate disable thing anyway.
>
> I don't see why it should depend on RT_PUSH_IPI, it never is actually
> migratable, and so it never makes sense to have on the pushable list.
>
> But perhaps I'm missing something; the above seems to suggest that is a
> theme today.