Skip to content

Commit 92c7010

Browse files
committed
Auto merge of #155609 - cuviper:thread_pool-seq-cst, r=jieyouxu
rustc_thread_pool: Make `CoreLatch::set` use `SeqCst` instead of `AcqRel` Every other modification of this variable uses `SeqCst`, which is justified in the sleep README. This particular choice of `AcqRel` was not discussed during its addition in rayon-rs/rayon#746, nor rayon-rs/rfcs#5, so I suspect was simply an oversight from earlier development. We probably do want this to participate in the same sequential consistency. The only other ordering difference is `CoreLatch::probe`'s load with `Acquire`, which should be fine because this doesn't need consistency with the sleep counters. See also rayon-rs/rayon#1297. As I commented there, I think in practice this would be quite rare to cause any problems, but it *could* be a source of non-deterministic bugs on targets with weak memory ordering.
2 parents 5095b44 + 29ccf67 commit 92c7010

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

compiler/rustc_thread_pool/src/latch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl CoreLatch {
117117
/// latch code.
118118
#[inline]
119119
unsafe fn set(this: *const Self) -> bool {
120-
let old_state = unsafe { (*this).state.swap(SET, Ordering::AcqRel) };
120+
let old_state = unsafe { (*this).state.swap(SET, Ordering::SeqCst) };
121121
old_state == SLEEPING
122122
}
123123

0 commit comments

Comments
 (0)