Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1349271

x86 memory barrier: why does Linux prefer MFENCE to Locked ADD?

From Dexuan Cui <decui@microsoft.com>
Newsgroups linux.kernel
Subject x86 memory barrier: why does Linux prefer MFENCE to Locked ADD?
Date 2016-03-03 16:10 +0100
Message-ID <r8D35-k8-37@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

x86 memory barrier: why does Linux prefer MFENCE to Locked ADD? Dexuan Cui <decui@microsoft.com> - 2016-03-03 16:10 +0100
  Re: x86 memory barrier: why does Linux prefer MFENCE to Locked ADD? Ingo Molnar <mingo@kernel.org> - 2016-03-03 16:30 +0100
    Re: x86 memory barrier: why does Linux prefer MFENCE to Locked ADD? Peter Zijlstra <peterz@infradead.org> - 2016-03-03 16:40 +0100
      Re: x86 memory barrier: why does Linux prefer MFENCE to Locked ADD? "Michael S. Tsirkin" <mst@redhat.com> - 2016-03-03 19:40 +0100
        Re: x86 memory barrier: why does Linux prefer MFENCE to Locked ADD? "H. Peter Anvin" <hpa@zytor.com> - 2016-03-03 20:10 +0100

csiph-web