Re: [PATCH tip/core/rcu 16/27] rcu: Add comment documenting how rcu_seq_snap works

From: Paul E. McKenney
Date: Tue Jun 26 2018 - 18:25:57 EST


On Tue, Jun 26, 2018 at 10:15:03PM +0200, Peter Zijlstra wrote:
> On Tue, Jun 26, 2018 at 12:31:46PM -0700, Paul E. McKenney wrote:
> > > Then the existing comment is misleading and really needs change.
> >
> > Would it be sufficient to add something like "The memory barrier is
> > required to support the many-to-many ordering guaranteed by RCU grace
> > periods"?
>
> What would lead me to wonder why after the load and not (also) before.

The memory barriers on the other sides of these primitives are supplied
by the caller. For example, in srcu_gp_end(), there is a set of
spin_unlock_irq_rcu_node()/spin_lock_irq_rcu_node() pairs between the
rcu_seq_end() of the prior SRCU grace period and the rcu_seq_start()
of the next one.

However, these things aren't anywhere near a fastpath, so I could add
the smp_mb() calls on the other sides for readability, if that would
be useful.

Thanx, Paul