diff options
author | Jens Axboe <axboe@kernel.dk> | 2023-05-17 20:23:41 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2023-05-17 21:14:11 +0200 |
commit | a2741c58ac677e5de35bba7dec6376579dd513cd (patch) | |
tree | 99316f456b6a8b9300ecaaf7d0091c104e0683ab /io_uring/net.c | |
parent | io_uring/net: push IORING_CQE_F_SOCK_NONEMPTY into io_recv_finish() (diff) | |
download | linux-a2741c58ac677e5de35bba7dec6376579dd513cd.tar.xz linux-a2741c58ac677e5de35bba7dec6376579dd513cd.zip |
io_uring/net: don't retry recvmsg() unnecessarily
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 <axboe@kernel.dk>
Diffstat (limited to 'io_uring/net.c')
-rw-r--r-- | io_uring/net.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/io_uring/net.c b/io_uring/net.c index 9e0034771dbb..0795f3783013 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -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. */ } |