Le Wed, Oct 25, 2023 at 10:40:08AM +0200, Peter Zijlstra a écrit :
> On Tue, Oct 24, 2023 at 11:46:23PM +0200, Frederic Weisbecker wrote:
> 
> > +/* Check for quiescent states since the pregp's synchronize_rcu() */
> > +static bool rcu_tasks_is_holdout(struct task_struct *t)
> > +{
> > +   int cpu;
> > +
> > +   /* Has the task been seen voluntarily sleeping? */
> > +   if (!READ_ONCE(t->on_rq))
> > +           return false;
> > +
> > +   cpu = task_cpu(t);
> > +
> > +   /*
> > +    * Idle tasks within the idle loop or offline CPUs are RCU-tasks
> > +    * quiescent states. But CPU boot code performed by the idle task
> > +    * isn't a quiescent state.
> > +    */
> > +   if (t == idle_task(cpu)) {
> > +           if (is_idle_task(t))
> > +                   return false;
> > +
> > +           if (!rcu_cpu_online(cpu))
> > +                   return false;
> > +   }
> 
> Hmm, why is this guarded by t == idle_task() ?
> 
> Notably, there is the idle-injection thing that uses FIFO tasks to run
> 'idle', see play_idle_precise(). This will (temporarily) get PF_IDLE on
> tasks that are not idle_task().

Ah good point. So indeed the is_idle_task() test doesn't musn't be
guarded by t == idle_task(cpu). But rcu_cpu_online() has to, otherwise
if it's not an idle task, there is a risk that the task gets migrated out
by the time we observe the old CPU offline.

Thanks.

> 
> > +
> > +   return true;
> > +}
> > +
> >  /* Per-task initial processing. */
> >  static void rcu_tasks_pertask(struct task_struct *t, struct list_head *hop)
> >  {
> > -   if (t != current && READ_ONCE(t->on_rq) && !is_idle_task(t)) {
> > +   if (t != current && rcu_tasks_is_holdout(t)) {
> 
> 

Reply via email to