From e2904728843ea14c2906d3649541e45d9f038591 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Wed, 30 Mar 2022 21:08:23 +0000 Subject: [PATCH 05/49] x86: Add a note on membar_sync and mfence. --- common/lib/libc/arch/i386/atomic/atomic.S | 6 ++++++ common/lib/libc/arch/x86_64/atomic/atomic.S | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/common/lib/libc/arch/i386/atomic/atomic.S b/common/lib/libc/arch/i386/atomic/atomic.S index d929dd25024d..ea71b2fb3c09 100644 --- a/common/lib/libc/arch/i386/atomic/atomic.S +++ b/common/lib/libc/arch/i386/atomic/atomic.S @@ -197,6 +197,12 @@ ENTRY(_membar_producer) END(_membar_producer) ENTRY(_membar_sync) + /* + * MFENCE, or a serializing instruction like a locked addq, + * is necessary to order store-before-load. Every other + * ordering -- load-before-anything, anything-before-store -- + * is already guaranteed without explicit barriers. + */ HOTPATCH_SSE2_MFENCE /* 7 bytes of instructions */ LOCK diff --git a/common/lib/libc/arch/x86_64/atomic/atomic.S b/common/lib/libc/arch/x86_64/atomic/atomic.S index 02554cd00edd..a940e7abfff6 100644 --- a/common/lib/libc/arch/x86_64/atomic/atomic.S +++ b/common/lib/libc/arch/x86_64/atomic/atomic.S @@ -272,6 +272,12 @@ ENTRY(_membar_producer) END(_membar_producer) ENTRY(_membar_sync) + /* + * MFENCE, or a serializing instruction like a locked addq, + * is necessary to order store-before-load. Every other + * ordering -- load-before-anything, anything-before-store -- + * is already guaranteed without explicit barriers. + */ HOTPATCH_SSE2_MFENCE /* 8 bytes of instructions */ LOCK -- 2.33.0