Re: [PATCH] rcu: Break rcu_node_0 --> &rq->__lock order

From: Paul E. McKenney
Date: Wed Nov 01 2023 - 12:52:09 EST


On Wed, Nov 01, 2023 at 03:38:14PM +0100, Peter Zijlstra wrote:
> On Wed, Nov 01, 2023 at 07:21:09PM +0800, Z qiang wrote:
>
> > > static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
> > > {
> > > unsigned long jtsq;
> > > + int ret = 0;
> > > struct rcu_node *rnp = rdp->mynode;
> > >
> > > /*
> > > @@ -847,8 +852,8 @@ static int rcu_implicit_dynticks_qs(stru
> > > (time_after(jiffies, READ_ONCE(rdp->last_fqs_resched) + jtsq * 3) ||
> > > rcu_state.cbovld)) {
> > > WRITE_ONCE(rdp->rcu_urgent_qs, true);
> > > - resched_cpu(rdp->cpu);
> > > WRITE_ONCE(rdp->last_fqs_resched, jiffies);
> > > + ret = -1;
> > > }
> > >
> >
> >
> > Maybe some modifications are missing here:
> >
> > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
> > index aa4c808978b8..77e7a0dc722a 100644
> > --- a/kernel/rcu/tree.c
> > +++ b/kernel/rcu/tree.c
> > @@ -867,8 +867,8 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
> > if (time_after(jiffies, rcu_state.jiffies_resched)) {
> > if (time_after(jiffies,
> > READ_ONCE(rdp->last_fqs_resched) + jtsq)) {
> > - resched_cpu(rdp->cpu);
> > WRITE_ONCE(rdp->last_fqs_resched, jiffies);
> > + ret = -1;
> > }
> > if (IS_ENABLED(CONFIG_IRQ_WORK) &&
> > !rdp->rcu_iw_pending && rdp->rcu_iw_gp_seq != rnp->gp_seq &&
> >
> >
>
> Bah, you're quite right, I missed that there were two sites calling
> resched_cpu().
>
> Paul, do you want a fixed up version or will you fold in the fix?

I can fold it in. I also clearly need to add a 15-second stall to at
least one of the rcutorture scenarios to exercise this code path...

(And Frederic might be pushing this one, his choice.)

Thanx, Paul