-
Notifications
You must be signed in to change notification settings - Fork 120
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
fix io_uring cancel_wait #264
fix io_uring cancel_wait #264
Conversation
io/iouring-wrapper.cpp
Outdated
} | ||
void run_wait_canceller() { | ||
uint32_t poll_mask = evmap.translate_bitwisely(EVENT_READ); | ||
async_io(&io_uring_prep_poll_multishot, -1, RingFlagsWaitCanceller, m_wait_canceller_fd, poll_mask); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait_canceller
will fall into sleep in async_io
. Because the multishot poll needs to keep the ioCtx
on stack for the whole time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually we don't need to use async_io() to register the multishot poll, and we can set the user data as nullptr.
When we get a event with nullptr data, we know it's cancel wait.
3d56c07
to
6305097
Compare
while (m_cancel_poller_running) { | ||
uint32_t poll_mask = evmap.translate_bitwisely(EVENT_READ); | ||
int ret = async_io(&io_uring_prep_poll_add, -1, 0, m_cancel_fd, poll_mask); | ||
if (ret < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not use one-shot poll. There is a risk of missing eventfd notification, right before starting the next round of polling.
Thanks for fixing this so quickly! I tested this locally and it eliminates the stalls in my workload. |
io/iouring-wrapper.cpp
Outdated
@@ -130,16 +131,17 @@ class iouringEngine : public MasterEventEngine, public CascadingEventEngine { | |||
|
|||
if (m_master) { | |||
// Setup a cancel poller to watch on master engine | |||
m_cancel_fd = eventfd(0, EFD_CLOEXEC); | |||
if (m_cancel_fd < 0) { | |||
m_wait_canceller_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_wait_canceller_fd and m_cascading_event_fd can be unified as m_eventfd?
io/iouring-wrapper.cpp
Outdated
} | ||
void run_wait_canceller() { | ||
uint32_t poll_mask = evmap.translate_bitwisely(EVENT_READ); | ||
async_io(&io_uring_prep_poll_multishot, -1, RingFlagsWaitCanceller, m_wait_canceller_fd, poll_mask); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually we don't need to use async_io() to register the multishot poll, and we can set the user data as nullptr.
When we get a event with nullptr data, we know it's cancel wait.
9e0ef9c
to
d889094
Compare
d889094
to
b5c5351
Compare
Fix #261