Re: [PATCH v34 08/14] sched/proxy: Invoke migrate_task_rq() on proxy-migration

From: John Stultz

Date: Wed Dec 02 2026 - 16:51:34 EST


On Wed, Dec 2, 2026 at 1:13 PM John Stultz <jstultz@xxxxxxxxxx> wrote:
>
> On Tue, Dec 1, 2026 at 10:39 PM K Prateek Nayak <kprateek.nayak@xxxxxxx> wrote:
> >
> > Hello John,
> >
> > On 12/2/2026 9:22 AM, John Stultz wrote:
> > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > > index 6a9fec7a26f67..863f4e3a2051f 100644
> > > --- a/kernel/sched/core.c
> > > +++ b/kernel/sched/core.c
> > > @@ -3444,6 +3444,16 @@ void relax_compatible_cpus_allowed_ptr(struct task_struct *p)
> > >
> > > #ifdef CONFIG_SMP
> >
> > I think it is more cleaner to take set_task_cpu() out of CONFIG_SMP
> > block since UP will just do a redundant __set_task_cpu() ...
> >
> > >
> > > +static void __do_migrate_task_rq(struct task_struct *p, unsigned int new_cpu)
> > > +{
> > > + if (task_cpu(p) != new_cpu) {
> > > + if (p->sched_class->migrate_task_rq)
> > > + p->sched_class->migrate_task_rq(p, new_cpu);
> > > + p->se.nr_migrations++;
> > > + perf_event_task_migrate(p);
> > > + }
> > > +}
> > > +
> > > void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
> > > {
> > > unsigned int state = READ_ONCE(p->__state);
> > > @@ -3493,15 +3503,11 @@ void set_task_cpu(struct task_struct *p, unsigned int new_cpu)
> > >
> > > trace_sched_migrate_task(p, new_cpu);
> > >
> > > - if (task_cpu(p) != new_cpu) {
> > > - if (p->sched_class->migrate_task_rq)
> > > - p->sched_class->migrate_task_rq(p, new_cpu);
> > > - p->se.nr_migrations++;
> > > - perf_event_task_migrate(p);
> > > - }
> > > -
> > > + __do_migrate_task_rq(p, new_cpu);
> > > __set_task_cpu(p, new_cpu);
> > > }
> > > +#else /* CONFIG_SMP */
> > > +static inline void __do_migrate_task_rq(struct task_struct *p, unsigned int new_cpu) {}
> > > #endif /* CONFIG_SMP */
> > >
> > > #ifdef CONFIG_NUMA_BALANCING
> > > @@ -6929,6 +6935,7 @@ static inline void proxy_set_task_cpu(struct task_struct *p, int cpu)
> > > * was previously runnable.
> > > */
> > > wake_cpu = p->wake_cpu;
> > > + __do_migrate_task_rq(p, cpu);
> > > __set_task_cpu(p, cpu);
> >
> > ... and just convert this to use set_task_cpu().
> >
> > We get the consistent sched_migrating traces to follow this task
> > and if I'm not mistaken, all the checks in set_task_cpu() should
> > be safe when called from all the proxy contexts after Andrea's
> > fixes the.
>
> Hrm. I guess my worry there was the trace event might not be wanted on
> proxy migrations, as existing tooling may not understand it,
> especially all the sleeping owner activations potentially bouncing
> things around.
>
> Otherwise, I guess it does look doable. I'll take a stab at it.

So, unfortunately (unless I'm missing another one of Andrea's
patches), we still hit the
WARN_ON_ONCE(state != TASK_RUNNING && state != TASK_WAKING && !p->on_rq);
warnings on sleeping owner activations when using the full set_task_cpu() via:
try_to_wake_up() -> activate_blocked_waiters() ->
do_activate_blocked_waiter() -> proxy_set_task_cpu() -> set_task_cpu()

I guess we could loosen that warning up as well? Any preferences?

thanks
-john