Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle coop_taskrun #263

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ impl<'a> Submitter<'a> {
}
}

/// CQ ring is overflown
fn sq_cq_overflow(&self) -> bool {
/// CQ ring is overflown or a deferred task is runnable. Either case requires entering the kernel
fn sq_cq_overflow_or_taskrun(&self) -> bool {
unsafe {
(*self.sq_flags).load(atomic::Ordering::Acquire) & sys::IORING_SQ_CQ_OVERFLOW != 0
(*self.sq_flags).load(atomic::Ordering::Acquire) & (sys::IORING_SQ_CQ_OVERFLOW | sys::IORING_SQ_TASKRUN) != 0
}
}

Expand Down Expand Up @@ -115,12 +115,12 @@ impl<'a> Submitter<'a> {
let len = self.sq_len();
let mut flags = 0;

// This logic suffers from the fact the sq_cq_overflow and sq_need_wakeup
// This logic suffers from the fact the sq_cq_overflow_or_taskrun and sq_need_wakeup
// 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.

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

Expand All @@ -145,7 +145,7 @@ impl<'a> Submitter<'a> {
let len = self.sq_len();
let mut flags = sys::IORING_ENTER_EXT_ARG;

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

Expand Down