about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAustin Kiekintveld <akiekintveld@icloud.com>2022-05-01 16:46:19 -0700
committerGitHub <noreply@github.com>2022-05-01 16:46:19 -0700
commitdf4457e20bb6017de97ff69af58a0a92a3a5b423 (patch)
treec96ea5bfa0ef09169cf9ebd46ccb7d6059dca267
parent4dd8b420c027001e47b0d811a7e55e2fe1de1395 (diff)
downloadrust-df4457e20bb6017de97ff69af58a0a92a3a5b423.tar.gz
rust-df4457e20bb6017de97ff69af58a0a92a3a5b423.zip
Relax memory ordering used in SameMutexCheck
`SameMutexCheck` only requires atomicity for `self.addr`, but does not need ordering of other memory accesses in either the success or failure case. Using `Relaxed`, the code still correctly handles the case when two threads race to store an address.
-rw-r--r--library/std/src/sys_common/condvar/check.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/sys_common/condvar/check.rs b/library/std/src/sys_common/condvar/check.rs
index 7671850ac55..69cad21b096 100644
--- a/library/std/src/sys_common/condvar/check.rs
+++ b/library/std/src/sys_common/condvar/check.rs
@@ -24,7 +24,7 @@ impl SameMutexCheck {
     }
     pub fn verify(&self, mutex: &MovableMutex) {
         let addr = mutex.raw() as *const imp::Mutex as *const () as *mut _;
-        match self.addr.compare_exchange(ptr::null_mut(), addr, Ordering::SeqCst, Ordering::SeqCst)
+        match self.addr.compare_exchange(ptr::null_mut(), addr, Ordering::Relaxed, Ordering::Relaxed)
         {
             Ok(_) => {}               // Stored the address
             Err(n) if n == addr => {} // Lost a race to store the same address