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

From: Paul E. McKenney
Date: Thu Jan 19 2023 - 13:43:44 EST


On Thu, Jan 19, 2023 at 11:41:01AM -0500, Alan Stern wrote:
> On Thu, Jan 19, 2023 at 12:22:50PM +0100, Jonas Oberhauser wrote:
> >
> >
> > On 1/19/2023 3:28 AM, Alan Stern wrote:
> > > > This is a permanent error; I've given up. Sorry it didn't
> > > work out.
> >
> > [It seems the e-mail still reached me through the mailing list]
>
> [For everyone else, Jonas is referring to the fact that the last two
> emails I sent to his huaweicloud.com address could not be delivered, so
> I copied them off-list to his huawei.com address.]
>
> > > > I consider that a hack though and don't like it.
> > > It _is_ a bit of a hack, but not a huge one. srcu_read_lock() really
> > > is a lot like a load, in that it returns a value obtained by reading
> > > something from memory (along with some other operations, though, so it
> > > isn't a simple straightforward read -- perhaps more like an
> > > atomic_inc_return_relaxed).
> > The issue I have with this is that it might create accidental ordering. How
> > does it behave when you throw fences in the mix?
>
> I think this isn't going to be a problem. Certainly any real
> implementation of scru_read_lock() is going to involve some actual load
> operations, so any unintentional ordering caused by fences will also
> apply to real executions. Likewise for srcu_read_unlock and store
> operations.
>
> > It really does not work like an increment at all, I think srcu_read_lock()
> > only reads the currently active index, but the index is changed by
> > srcu_sync. But even that is an implementation detail of sorts. I think the
> > best way to think of it would be for srcu_read_lock to just return an
> > arbitrary value.
>
> I think I'll stick to it always returning the initial value. Paul said
> that would be okay.

Just confirming.

> > The user can not rely on any kind of "accidental" rfe edges between these
> > events for ordering.
> >
> > Perhaps if you flag any use of these values in address or control
> > dependencies, as well as any event which depends on more than one of these
> > values, you could prove that it's impossible to contrain the behavior
> > through these rfe(and/or co) edges because you can anyways never inspect the
> > value returned by the operation (except to pass it into srcu_unlock).
> >
> > Or you might be able to explicitly eliminate the events everywhere, just
> > like you have done for carry-dep in your patch.
>
> On second thought, I'll make it impossible to read from the
> srcu_read_unlock events by removing them from the rf (and rfi/rfe)
> relation. Then it won't be necessary to change carry-dep or anything
> else.

Although that works very well for srcu_read_lock() and srcu_read_unlock(),
it would be an issue for srcu_down_read() and srcu_up_read(). But one
thing at a time! ;-)

Thanx, Paul