Skip to content

Commit

Permalink
Fix Submit use of NEED_WAKEUP flag
Browse files Browse the repository at this point in the history
  • Loading branch information
HeroicKatora committed Apr 27, 2024
1 parent d8c3d7f commit 0360013
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'a> Submitter<'a> {
#[inline]
fn sq_need_wakeup(&self) -> bool {
unsafe {
(*self.sq_flags).load(atomic::Ordering::Acquire) & sys::IORING_SQ_NEED_WAKEUP != 0
(*self.sq_flags).load(atomic::Ordering::Relaxed) & sys::IORING_SQ_NEED_WAKEUP != 0
}
}

Expand Down Expand Up @@ -119,12 +119,17 @@ impl<'a> Submitter<'a> {
// each cause an atomic load of the same variable, self.sq_flags.
// In the hottest paths, when a server is running with sqpoll,
// this is going to be hit twice, when once would be sufficient.
// However, consider that the `SeqCst` barrier required for interpreting
// the IORING_ENTER_SQ_WAKEUP bit is required in all paths where sqpoll
// is setup when consolidating the reads.

if want > 0 || self.params.is_setup_iopoll() || self.sq_cq_overflow() {
flags |= sys::IORING_ENTER_GETEVENTS;
}

if self.params.is_setup_sqpoll() {
// See discussion in [`SubmissionQueue::need_wakeup`].
atomic::fence(atomic::Ordering::SeqCst);
if self.sq_need_wakeup() {
flags |= sys::IORING_ENTER_SQ_WAKEUP;
} else if want == 0 {
Expand All @@ -150,6 +155,8 @@ impl<'a> Submitter<'a> {
}

if self.params.is_setup_sqpoll() {
// See discussion in [`SubmissionQueue::need_wakeup`].
atomic::fence(atomic::Ordering::SeqCst);
if self.sq_need_wakeup() {
flags |= sys::IORING_ENTER_SQ_WAKEUP;
} else if want == 0 {
Expand Down

0 comments on commit 0360013

Please sign in to comment.