Re: [PATCH v3] sched/rt: Do not account migrate-disabled tasks as pushable

From: Peter Zijlstra

Date: Thu Nov 19 2026 - 11:41:05 EST


On Thu, Nov 19, 2026 at 04:28:27PM +0100, Peter Zijlstra wrote:
> On Thu, Nov 19, 2026 at 04:17:40PM +0100, Peter Zijlstra wrote:
> > On Thu, Nov 19, 2026 at 04:08:12PM +0100, Peter Zijlstra wrote:
> > > On Thu, Nov 19, 2026 at 12:06:21PM +0000, Mel Gorman wrote:
> > >
> > > > > > > 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.
> > > > > > >
> > > >
> > > > Short summary, this assumption is wrong, nr_cpus_allowed is not updated
> > > > in that path.
> >
> > > Bah, and I cannot remember either. Let me have a poke, see if something
> > > bubbles up.
> >
> > So this version did update nr_cpus_allowed:
> >
> > https://patch.msgid.link/20200921163845.769861942%40infradead.org
> >
> > And the next version it did not:
> >
> > https://patch.msgid.link/20201005150921.859981475%40infradead.org
> >
> > But I can't seem to locate quite yet why it changed.
>
> Tada!
>
> https://patch.msgid.link/20200924123527.GJ2628%40hirez.programming.kicks-ass.net
>
> I'm leaning towards "we got it wrong" on this.

One issue seems to be concurrent set_cpus_allowed_ptr(); the current
rule is that nr_cpus_allowed is the number of bits in p->cpus_mask.

I'm not sure changing this is going to be 'trivial', so perhaps
sprinkling more is_migration_disabled() is the simple solution for now.
Dunno.