public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* x86 memory barrier: why does Linux prefer MFENCE to Locked ADD?
@ 2016-03-03 14:33 Dexuan Cui
  2016-03-03 15:27 ` Ingo Molnar
  0 siblings, 1 reply; 10+ messages in thread
From: Dexuan Cui @ 2016-03-03 14:33 UTC (permalink / raw)
  To: linux-x86_64@vger.kernel.org, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, David Howells, Paul E. McKenney
  Cc: linux-kernel@vger.kernel.org

Hi,
My understanding about arch/x86/include/asm/barrier.h is: obviously Linux
more likes {L,S,M}FENCE -- Locked ADD is only used in x86_32 platforms that
don't support XMM2.

However, it looks people say Locked Add is much faster than the FENCE
instructions, even on modern Intel CPUs like Haswell, e.g., please see
the three sources:

" 11.5.1 Locked Instructions as Memory Barriers
Optimization
Use locked instructions to implement Store/Store and Store/Load barriers.
"
http://support.amd.com/TechDocs/47414_15h_sw_opt_guide.pdf

"lock addl %(rsp), 0 is a better solution for StoreLoad barrier ":
http://shipilev.net/blog/2014/on-the-fence-with-dependencies/

"...locked instruction are more efficient barriers...":
http://www.pvk.ca/Blog/2014/10/19/performance-optimisation-~-writing-an-essay/

I also found that FreeBSD prefers Locked Add.

So, I'm curious why Linux prefers MFENCE.
I guess I may be missing something.

I tried to google the question, but didn't find an answer.

Thanks,
-- Dexuan

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

end of thread, other threads:[~2016-08-03 23:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-03 14:33 x86 memory barrier: why does Linux prefer MFENCE to Locked ADD? Dexuan Cui
2016-03-03 15:27 ` Ingo Molnar
2016-03-03 15:34   ` Peter Zijlstra
2016-03-03 18:35     ` Michael S. Tsirkin
2016-03-03 19:05       ` H. Peter Anvin
2016-06-03 13:39         ` Peter Zijlstra
2016-08-03  4:36         ` Michael S. Tsirkin
2016-08-03 12:50           ` Henrique de Moraes Holschuh
2016-08-03 13:04             ` Michael S. Tsirkin
2016-08-03 23:19               ` Henrique de Moraes Holschuh

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