Re: [PATCH v2 4/6] rcu-tasks: Maintain lists to eliminate RCU-tasks/do_exit() deadlocks

Paul E. McKenney
2024-02-24T00:28:24Z

On Fri, Feb 23, 2024 at 01:19:42PM +0100, Frederic Weisbecker wrote:
> On Fri, Feb 16, 2024 at 05:27:39PM -0800, Boqun Feng wrote:
> > -void exit_tasks_rcu_start(void) __acquires(&tasks_rcu_exit_srcu)
> > +void exit_tasks_rcu_start(void)
> > {
> > - current->rcu_tasks_idx = __srcu_read_lock(&tasks_rcu_exit_srcu);
> > + unsigned long flags;
> > + struct rcu_tasks_percpu *rtpcp;
> > + struct task_struct *t = current;
> > +
> > + WARN_ON_ONCE(!list_empty(&t->rcu_tasks_exit_list));
> > + preempt_disable();
> > + rtpcp = this_cpu_ptr(rcu_tasks.rtpcpu);
> > + t->rcu_tasks_exit_cpu = smp_processor_id();
> > + raw_spin_lock_irqsave_rcu_node(rtpcp, flags);
> > + if (!rtpcp->rtp_exit_list.next)
>
> And then you might want to turn that into a WARN_ONCE.

Excellent point, thank you!

I am queueing a separate patch for this with your Reported-by. (This
change can lag behind, just in case this series needs to go in quickly.)

Thanx, Paul

> Thanks.
>
> > + INIT_LIST_HEAD(&rtpcp->rtp_exit_list);
> > + list_add(&t->rcu_tasks_exit_list, &rtpcp->rtp_exit_list);
> > + raw_spin_unlock_irqrestore_rcu_node(rtpcp, flags);
> > + preempt_enable();
> > }