Skip to content

Commit

Permalink
io_uring/net: don't retry recvmsg() unnecessarily
Browse files Browse the repository at this point in the history
If we're doing multishot receives, then we always end up doing two trips
through sock_recvmsg(). For protocols that sanely set msghdr->msg_inq,
then we don't need to waste time picking a new buffer and attempting a
new receive if there's nothing there.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed May 17, 2023
1 parent 7d41bcb commit a2741c5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion io_uring/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,15 @@ static inline bool io_recv_finish(struct io_kiocb *req, int *ret,
if (io_aux_cqe(req->ctx, issue_flags & IO_URING_F_COMPLETE_DEFER,
req->cqe.user_data, *ret, cflags | IORING_CQE_F_MORE, true)) {
io_recv_prep_retry(req);
return false;
/* Known not-empty or unknown state, retry */
if (cflags & IORING_CQE_F_SOCK_NONEMPTY ||
msg->msg_inq == -1U)
return false;
if (issue_flags & IO_URING_F_MULTISHOT)
*ret = IOU_ISSUE_SKIP_COMPLETE;
else
*ret = -EAGAIN;
return true;
}
/* Otherwise stop multishot but use the current result. */
}
Expand Down

0 comments on commit a2741c5

Please sign in to comment.