linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire
@ 2018-07-10 16:25 Paul E. McKenney
       [not found] ` <Pine.LNX.4.44L0.1807101416390.1449-100000@iolanthe.rowland.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Paul E. McKenney @ 2018-07-10 16:25 UTC (permalink / raw)
  To: Alan Stern
  Cc: LKMM Maintainers -- Akira Yokosawa, Andrea Parri, Boqun Feng,
	Daniel Lustig, David Howells, Jade Alglave, Luc Maranget,
	Nicholas Piggin, Peter Zijlstra, Will Deacon,
	Kernel development list

On Tue, Jul 10, 2018 at 09:57:17AM -0400, Alan Stern wrote:
> On Mon, 9 Jul 2018, Paul E. McKenney wrote:
> 
> > On Mon, Jul 09, 2018 at 04:01:57PM -0400, Alan Stern wrote:
> > > More than one kernel developer has expressed the opinion that the LKMM
> > > should enforce ordering of writes by locking.  In other words, given
> > > the following code:
> > > 
> > > 	WRITE_ONCE(x, 1);
> > > 	spin_unlock(&s):
> > > 	spin_lock(&s);
> > > 	WRITE_ONCE(y, 1);
> > > 
> > > the stores to x and y should be propagated in order to all other CPUs,
> > > even though those other CPUs might not access the lock s.  In terms of
> > > the memory model, this means expanding the cumul-fence relation.
> > > 
> > > Locks should also provide read-read (and read-write) ordering in a
> > > similar way.  Given:
> > > 
> > > 	READ_ONCE(x);
> > > 	spin_unlock(&s);
> > > 	spin_lock(&s);
> > > 	READ_ONCE(y);		// or WRITE_ONCE(y, 1);
> > > 
> > > the load of x should be executed before the load of (or store to) y.
> > > The LKMM already provides this ordering, but it provides it even in
> > > the case where the two accesses are separated by a release/acquire
> > > pair of fences rather than unlock/lock.  This would prevent
> > > architectures from using weakly ordered implementations of release and
> > > acquire, which seems like an unnecessary restriction.  The patch
> > > therefore removes the ordering requirement from the LKMM for that
> > > case.
> > > 
> > > All the architectures supported by the Linux kernel (including RISC-V)
> > > do provide this ordering for locks, albeit for varying reasons.
> > > Therefore this patch changes the model in accordance with the
> > > developers' wishes.
> > > 
> > > Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> > 
> > Nice!
> > 
> > However, it doesn't apply against current -rcu.  Am I missing a patch?
> > Or is this supposed to apply against origin/lkmm?
> 
> I wrote it based on 4.18-rc.  However, I can rebase it against your
> current dev branch.

Could you please?  Against either the dev or lkmm branch should well.

If you don't have time for this, my approach would be to apply against
4.18-rc, then cherry-pick onto my branch, resolving the conflicts and
emailing you both the "<<<<"-marked file and my proposed resolution.
(Or git might just resolve everything automatically -- that does
sometimes happen.  But it would still be good to double-check its work,
as it sometimes does "interesting" resolutions.)

							Thanx, Paul


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-07-11 18:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <3344e7aeb09644758860ac343bd757a1@AcuMS.aculab.com>
2018-07-11 17:36 ` [PATCH v3] tools/memory-model: Add extra ordering for locks and remove it for ordinary release/acquire Alan Stern
2018-07-10 16:25 [PATCH v2] " Paul E. McKenney
     [not found] ` <Pine.LNX.4.44L0.1807101416390.1449-100000@iolanthe.rowland.org>
2018-07-10 19:58   ` [PATCH v3] " Paul E. McKenney
2018-07-10 20:24     ` Alan Stern
2018-07-10 20:31       ` Paul E. McKenney
2018-07-11  9:43   ` Will Deacon
2018-07-11 15:42     ` Paul E. McKenney
2018-07-11 16:17       ` Andrea Parri
2018-07-11 18:03         ` Paul E. McKenney
2018-07-11 16:34     ` Peter Zijlstra
2018-07-11 18:10       ` Paul E. McKenney

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox