Re: Internal vs. external barriers (was: Re: Interesting LKMM litmus test)

Alan Stern
2023-01-19T02:19:22Z

On Wed, Jan 18, 2023 at 04:02:14PM -0800, Paul E. McKenney wrote:
> On Wed, Jan 18, 2023 at 03:54:47PM -0500, Alan Stern wrote:
> > How does this differ from srcu_read_lock() and srcu_read_unlock()? And
> > how do the "up" and "down" parts figure into it? -- what is going up or
> > down?
>
> Functionally and from a performance/scalability viewpoint, they
> are identical to srcu_read_lock() and srcu_read_unlock(). The only
> difference is that srcu_down_read() and srcu_up_read() lack the lockdep
> machinery that complains when a matching pair of srcu_read_lock() and
> srcu_read_unlock() are used from different tasks.

This makes me wonder if there's any need for srcu_down_read and
srcu_up_read at all. Why not just use srcu_read_lock and
srcu_read_unlock, and remove the lockdep check?

> Within the implementation, nothing ever goes down, it is all
> this_cpu_inc(). The "down" and "up" are by analogy to down() and up(),
> where "down()" says acquire some rights to a resource and "up()" says
> release those rights.

Another reason not to use those names. If you insist on making these
operations distinct from srcu_read_lock and srcu_read_unlock, why not
borrow the "_get" and "_put" nomenclature used by the device core? I
suspect more people would associate them with acquiring and releasing
rights to a resource. (Although in this case it might be so clear
exactly what that resource is.)

> Wait, I can make "down" work.
>
> A call to srcu_down_read() reduces the quantity computed by summing the
> unlocks then subtracting the sum of the locks. A call to srcu_up_read()
> increases that same quantity. ;-)

I can't honestly call that a resoundingly convincing argument. :-)

Alan