Skip to content

Commit

Permalink
Replace SeqCst with AcqRel
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasdezeeuw committed Jan 26, 2025
1 parent 773daa2 commit cc283e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl AtomicBitMap {
let mut i = value.trailing_ones();
while i < usize::BITS {
// Attempt to set the bit, claiming the slot.
value = data.fetch_or(1 << i, Ordering::SeqCst);
value = data.fetch_or(1 << i, Ordering::AcqRel);
// Another thread could have attempted to set the same bit we're
// setting, so we need to make sure we actually set the bit
// (i.e. check if was unset in the previous state).
Expand All @@ -55,7 +55,7 @@ impl AtomicBitMap {
pub(crate) fn make_available(&self, index: usize) {
let idx = index / usize::BITS as usize;
let n = index % usize::BITS as usize;
let old_value = self.data[idx].fetch_and(!(1 << n), Ordering::SeqCst);
let old_value = self.data[idx].fetch_and(!(1 << n), Ordering::AcqRel);
debug_assert!(!is_unset(old_value, n));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/io_uring/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl ReadBufPool {
debug_assert!(pool_size.is_power_of_two());

let ring_fd = sq.inner.shared_data().rfd.as_raw_fd();
let id = ID.fetch_add(1, Ordering::SeqCst);
let id = ID.fetch_add(1, Ordering::AcqRel);

// These allocations must be page aligned.
let page_size = page_size();
Expand Down Expand Up @@ -182,7 +182,7 @@ impl ReadBufPool {
bid: buf_id,
resv: 0,
});
ring_tail.store(tail.wrapping_add(1), Ordering::SeqCst);
ring_tail.store(tail.wrapping_add(1), Ordering::Release);
drop(guard);
}

Expand Down

0 comments on commit cc283e0

Please sign in to comment.