diff mbox series

[2/3] io_uring/net: avoid redundant -ENOBUFS on recv multishot retry

Message ID 20240227185208.986844-3-axboe@kernel.dk (mailing list archive)
State New
Headers show
Series Misc io_uring networking | expand

Commit Message

Jens Axboe Feb. 27, 2024, 6:51 p.m. UTC
Now that we know if the buffer list is empty upfront, there's no point
doing a retry for that case. This can help avoid a redundant -ENOBUFS
which would terminate the multishot receive, requiring the app to
re-arm it.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
 io_uring/net.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/io_uring/net.c b/io_uring/net.c
index 9fe2a11f3554..ef91a1af6ba6 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -716,6 +716,11 @@  static inline bool io_recv_finish(struct io_kiocb *req, int *ret,
 		int mshot_retry_ret = IOU_ISSUE_SKIP_COMPLETE;
 
 		io_recv_prep_retry(req);
+
+		/* buffer list now empty, no point trying again */
+		if (req->flags & REQ_F_BL_EMPTY)
+			goto enobufs;
+
 		/* Known not-empty or unknown state, retry */
 		if (cflags & IORING_CQE_F_SOCK_NONEMPTY || msg->msg_inq == -1) {
 			if (sr->nr_multishot_loops++ < MULTISHOT_MAX_RETRY)
@@ -724,6 +729,7 @@  static inline bool io_recv_finish(struct io_kiocb *req, int *ret,
 			sr->nr_multishot_loops = 0;
 			mshot_retry_ret = IOU_REQUEUE;
 		}
+enobufs:
 		if (issue_flags & IO_URING_F_MULTISHOT)
 			*ret = mshot_retry_ret;
 		else