From 2d49b0795eaed17c63972cc3d75e633d3e33724c Mon Sep 17 00:00:00 2001 From: "Brian J. Cardiff" Date: Wed, 8 Feb 2023 09:19:02 -0300 Subject: [PATCH] Add memory barriers on lock/unlock of SpinLock (#13050) --- src/crystal/spin_lock.cr | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/crystal/spin_lock.cr b/src/crystal/spin_lock.cr index f0b4b2df4ab6..e3136cdf3fe9 100644 --- a/src/crystal/spin_lock.cr +++ b/src/crystal/spin_lock.cr @@ -11,11 +11,17 @@ class Crystal::SpinLock Intrinsics.pause end end + {% if flag?(:aarch64) %} + Atomic::Ops.fence :sequentially_consistent, false + {% end %} {% end %} end def unlock {% if flag?(:preview_mt) %} + {% if flag?(:aarch64) %} + Atomic::Ops.fence :sequentially_consistent, false + {% end %} @m.lazy_set(0) {% end %} end