From 0d36329f931b1c436b1ac7faf31f793f27b47e69 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sun, 11 Feb 2024 16:49:02 +0200 Subject: [PATCH] reactor: io_uring: poll first on send/recv Our speculation mechanism tries to predict if data is available in the socket (recv) or if there is room in the write buffer (send) and issues the syscall directly if so. It may make more sense to change it later, but for now, the expectation is that the request will not be completed immediately. Make use of this information by setting the IORING_RECVSEND_POLL_FIRST flag. This tells io_uring not to try to complete the request immediately, and instead issue a poll first. --- src/core/reactor_backend.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/reactor_backend.cc b/src/core/reactor_backend.cc index ff098591c4d..d5b5e2e64dc 100644 --- a/src/core/reactor_backend.cc +++ b/src/core/reactor_backend.cc @@ -1441,21 +1441,25 @@ class reactor_backend_uring final : public reactor_backend { case o::recv: { const auto& op = req.as(); ::io_uring_prep_recv(sqe, op.fd, op.addr, op.size, op.flags); + sqe->ioprio |= IORING_RECVSEND_POLL_FIRST; break; } case o::recvmsg: { const auto& op = req.as(); ::io_uring_prep_recvmsg(sqe, op.fd, op.msghdr, op.flags); + sqe->ioprio |= IORING_RECVSEND_POLL_FIRST; break; } case o::send: { const auto& op = req.as(); ::io_uring_prep_send(sqe, op.fd, op.addr, op.size, op.flags); + sqe->ioprio |= IORING_RECVSEND_POLL_FIRST; break; } case o::sendmsg: { const auto& op = req.as(); ::io_uring_prep_sendmsg(sqe, op.fd, op.msghdr, op.flags); + sqe->ioprio |= IORING_RECVSEND_POLL_FIRST; break; } case o::accept: {