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

fix io_uring cancel_wait #264

Merged

Conversation

beef9999
Copy link
Collaborator

@beef9999 beef9999 commented Nov 19, 2023

Fix #261

}
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);
}
Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

@beef9999 beef9999 force-pushed the beef9999/fix-iouring-cancel-wait branch 2 times, most recently from 3d56c07 to 6305097 Compare November 19, 2023 15:09
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) {
Copy link
Collaborator Author

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.

@louiswilliams
Copy link
Contributor

Thanks for fixing this so quickly! I tested this locally and it eliminates the stalls in my workload.

@@ -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);
Copy link
Collaborator

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?

}
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);
}
Copy link
Collaborator

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.

@beef9999 beef9999 force-pushed the beef9999/fix-iouring-cancel-wait branch 2 times, most recently from 9e0ef9c to d889094 Compare November 20, 2023 07:11
@beef9999 beef9999 force-pushed the beef9999/fix-iouring-cancel-wait branch from d889094 to b5c5351 Compare November 20, 2023 07:21
@beef9999 beef9999 merged commit 0a012f6 into alibaba:release/0.7 Nov 20, 2023
7 checks passed
@beef9999 beef9999 deleted the beef9999/fix-iouring-cancel-wait branch December 21, 2023 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants