Skip to content

Commit 8385d17

Browse files
authored
Rollup merge of #96616 - akiekintveld:min_stack_relaxed_ordering, r=joshtriplett
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.
2 parents 1318d94 + 63a90ef commit 8385d17

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/std/src/sys_common/thread.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::sys::thread as imp;
44

55
pub fn min_stack() -> usize {
66
static MIN: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
7-
match MIN.load(Ordering::SeqCst) {
7+
match MIN.load(Ordering::Relaxed) {
88
0 => {}
99
n => return n - 1,
1010
}
@@ -13,6 +13,6 @@ pub fn min_stack() -> usize {
1313

1414
// 0 is our sentinel value, so ensure that we'll never see 0 after
1515
// initialization has run
16-
MIN.store(amt + 1, Ordering::SeqCst);
16+
MIN.store(amt + 1, Ordering::Relaxed);
1717
amt
1818
}

0 commit comments

Comments
 (0)