[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230114175343.GF2948950@paulmck-ThinkPad-P17-Gen-1>
Date: Sat, 14 Jan 2023 09:53:43 -0800
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Jonas Oberhauser <jonas.oberhauser@...wei.com>
Cc: Alan Stern <stern@...land.harvard.edu>,
Peter Zijlstra <peterz@...radead.org>,
"parri.andrea" <parri.andrea@...il.com>, will <will@...nel.org>,
"boqun.feng" <boqun.feng@...il.com>, npiggin <npiggin@...il.com>,
dhowells <dhowells@...hat.com>,
"j.alglave" <j.alglave@....ac.uk>,
"luc.maranget" <luc.maranget@...ia.fr>, akiyks <akiyks@...il.com>,
dlustig <dlustig@...dia.com>, joel <joel@...lfernandes.org>,
urezki <urezki@...il.com>,
quic_neeraju <quic_neeraju@...cinc.com>,
frederic <frederic@...nel.org>,
Kernel development list <linux-kernel@...r.kernel.org>
Subject: Re: Internal vs. external barriers (was: Re: Interesting LKMM litmus
test)
On Fri, Jan 13, 2023 at 08:43:42PM +0000, Jonas Oberhauser wrote:
>
>
> -----Original Message-----
> From: Paul E. McKenney [mailto:paulmck@...nel.org]
>
> > (* Compute matching pairs of Srcu-lock and Srcu-unlock *) let srcu-rscs = ([Srcu-lock] ; rfi ; [Srcu-unlock]) & loc
>
> How does the Srcu-unlock read from the Srcu-lock? Is there something in your model or in herd that lets it understand lock and unlock should be treated as writes resp. reads from that specific location?
>
> Or do you mean that value given to Srcu-unlock should be the value produced by Srcu-lock?
Yes, and in the Linux kernel one does something like this:
idx = srcu_read_lock(&mysrcu);
// critical section
srcu_read_unlock(&mysrcu, idx);
> Perhaps the closest to what you want is to express that as a data dependency if you know how to teach herd that Srcu-unlock is a read and Srcu-lock depends on its second input :D (I have no idea how to do that, hence the questions above)
Given that both you and Alan suggested it, I must try it. ;-)
> Then you could flag if there's a data dependency from more than one event, meaning that the value is not purely the Srcu-lock-produced value.
Good point, thank you!
> That doesn't guarantee you that you don't do some nasty stuff with constant values though.
That is the purpose of this statement in the srcu_read_unlock()
implementation:
WARN_ON_ONCE(idx & ~0x1);
But yes, this WARN_ON_ONCE() can of course be fooled.
> Could you maybe use an opaque datatype for the values?
We could put it in a struct or something. The problem with making it
completely opaque is that the users must store it somewhere, which means
that the compiler needs to know how big it is. Of course, languages
other than C have other ways to make this happen. And correspondingly
slower build times. ;-)
Thanx, Paul
Powered by blists - more mailing lists