Re: [RFC][PATCH 5/5] sched: Add ttwu_queue support for delayed tasks

From: Peter Zijlstra
Date: Wed Jun 11 2025 - 05:39:52 EST


On Fri, Jun 06, 2025 at 06:55:37PM +0200, Vincent Guittot wrote:
> > > > @@ -3830,12 +3859,41 @@ void sched_ttwu_pending(void *arg)
> > > > update_rq_clock(rq);
> > > >
> > > > llist_for_each_entry_safe(p, t, llist, wake_entry.llist) {
> > > > + struct rq *p_rq = task_rq(p);
> > > > + int ret;
> > > > +
> > > > + /*
> > > > + * This is the ttwu_runnable() case. Notably it is possible for
> > > > + * on-rq entities to get migrated -- even sched_delayed ones.
> > >
> > > I haven't found where the sched_delayed task could migrate on another cpu.
> >
> > Doesn't happen often, but it can happen. Nothing really stops it from
> > happening. Eg weight based balancing can do it. As can numa balancing
> > and affinity changes.
>
> Yes, I agree that delayed tasks can migrate because of load balancing
> but not at wake up.

Right, but this here is the case where wakeup races with load-balancing.
Specifically, due to the wake_list, the wakeup can happen while the task
is on CPU N, and by the time the IPI gets processed the task has moved
to CPU M.

It doesn't happen often, but it was 'fun' chasing that fail around for a
day :/