about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAustin Kiekintveld <akiekintveld@icloud.com>2022-05-01 15:55:54 -0700
committerGitHub <noreply@github.com>2022-05-01 15:55:54 -0700
commit63a90efe2fd7ce733274684cba004ffad68c48fe (patch)
tree4e161ff2074abda75ebd407ce83c6f1d534c7702
parenta933de83989471ac444a13d62996d30621542654 (diff)
downloadrust-63a90efe2fd7ce733274684cba004ffad68c48fe.tar.gz
rust-63a90efe2fd7ce733274684cba004ffad68c48fe.zip
Relax memory ordering used in `min_stack`
`min_stack` does not provide any synchronization guarantees to its callers, and only requires atomicity for `MIN` itself, so relaxed memory ordering is sufficient.
-rw-r--r--library/std/src/sys_common/thread.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/sys_common/thread.rs b/library/std/src/sys_common/thread.rs
index f3a8bef8f71..76466b2b37b 100644
--- a/library/std/src/sys_common/thread.rs
+++ b/library/std/src/sys_common/thread.rs
@@ -4,7 +4,7 @@ use crate::sys::thread as imp;
 
 pub fn min_stack() -> usize {
     static MIN: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
-    match MIN.load(Ordering::SeqCst) {
+    match MIN.load(Ordering::Relaxed) {
         0 => {}
         n => return n - 1,
     }
@@ -13,6 +13,6 @@ pub fn min_stack() -> usize {
 
     // 0 is our sentinel value, so ensure that we'll never see 0 after
     // initialization has run
-    MIN.store(amt + 1, Ordering::SeqCst);
+    MIN.store(amt + 1, Ordering::Relaxed);
     amt
 }