linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] atomic: Fixes to smp_mb__{before,after}_atomic() and mips.
@ 2019-06-13 13:43 Peter Zijlstra
  2019-06-13 13:43 ` [PATCH v2 1/4] mips/atomic: Fix cmpxchg64 barriers Peter Zijlstra
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Peter Zijlstra @ 2019-06-13 13:43 UTC (permalink / raw)
  To: stern, akiyks, andrea.parri, boqun.feng, dlustig, dhowells,
	j.alglave, luc.maranget, npiggin, paulmck, peterz, will.deacon,
	paul.burton
  Cc: linux-kernel, torvalds

Hi,

This all started when Andrea Parri found a 'surprising' behaviour for x86:

  http://lkml.kernel.org/r/20190418125412.GA10817@andrea

Basically we fail for:

	*x = 1;
	atomic_inc(u);
	smp_mb__after_atomic();
	r0 = *y;

Because, while the atomic_inc() implies memory order, it
(surprisingly) does not provide a compiler barrier. This then allows
the compiler to re-order like so:

	atomic_inc(u);
	*x = 1;
	smp_mb__after_atomic();
	r0 = *y;

Which the CPU is then allowed to re-order (under TSO rules) like:

	atomic_inc(u);
	r0 = *y;
	*x = 1;

And this very much was not intended.

This had me audit all the (strong) architectures that had weak
smp_mb__{before,after}_atomic: ia64, mips, sparc, s390, x86, xtensa.

Of those, only x86 and mips were affected. Looking at MIPS to solve this, led
to the other MIPS patches.

All these patches have been through 0day for quite a while.

Paul, how do you want to route the MIPS bits?


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

end of thread, other threads:[~2019-08-31 10:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-13 13:43 [PATCH v2 0/4] atomic: Fixes to smp_mb__{before,after}_atomic() and mips Peter Zijlstra
2019-06-13 13:43 ` [PATCH v2 1/4] mips/atomic: Fix cmpxchg64 barriers Peter Zijlstra
2019-06-13 13:43 ` [PATCH v2 2/4] mips/atomic: Fix loongson_llsc_mb() wreckage Peter Zijlstra
2019-06-13 13:43 ` [PATCH v2 3/4] mips/atomic: Fix smp_mb__{before,after}_atomic() Peter Zijlstra
2019-06-13 13:43 ` [PATCH v2 4/4] x86/atomic: " Peter Zijlstra
2019-06-13 14:02   ` Will Deacon
2019-06-13 14:25 ` [PATCH v2 0/4] atomic: Fixes to smp_mb__{before,after}_atomic() and mips David Howells
2019-06-13 16:58   ` Alan Stern
2019-06-13 18:00     ` Peter Zijlstra
2019-06-13 16:32 ` Paul Burton
2019-06-13 17:48   ` Peter Zijlstra
2019-08-31  9:00 ` Peter Zijlstra
2019-08-31 10:02   ` Paul Burton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).