Skip to contentSkip to conversation

small io_uring/net fixes and uapi improvements

PATCH Applied Pavel Begunkov 2 participants 5 messages Aug 15, 2022 – Aug 16, 2022 io_uring

lore
Share & tools
lore
#0 lore raw

cover small io_uring/net fixes and uapi improvements

Just a random bunch of changes we need in 5.20

Pavel Begunkov (3):
io_uring/net: use right helpers for async recycle io_uring/net: improve zc addr import error handling io_uring/notif: raise limit on notification slots

 io_uring/net.c   | 18 +++++++++---------
 io_uring/notif.h |  2 +-
 2 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.37.0
#1 lore raw

PATCH 1/3 io_uring/net: use right helpers for async recycle

We have a helper that checks for whether a request contains anything in ->async_data or not, namely req_has_async_data(). It's better to use it as it might have some extra considerations.

Fixes 43e0bbbd0b0e3 ("io_uring: add netmsg cache")
---
 io_uring/net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/net.c +1 -1
index 6d71748e2c5a..2129562bfd9f 100644
@@ -116,7 +116,7 @@ static void io_netmsg_recycle(struct io_kiocb *req, unsigned int issue_flags)
 {
 	struct io_async_msghdr *hdr = req->async_data;
 
-	if (!hdr || issue_flags & IO_URING_F_UNLOCKED)
+	if (!req_has_async_data(req) || issue_flags & IO_URING_F_UNLOCKED)
 		return;
 
 	/* Let normal cleanup path reap it if we fail adding to the cache */
Signature · 1 line
2.37.0
#2 lore raw

PATCH 2/3 io_uring/net: improve zc addr import error handling

In reply to Pavel Begunkov

We may account memory to a memcg of a request that didn't even got to the network layer. It's not a bug as it'll be routinely cleaned up on flush, but it might be confusing for the userspace.

---
 io_uring/net.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
io_uring/net.c +8 -8
index 2129562bfd9f..f7cbd716817f 100644
@@ -977,6 +977,14 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
 	msg.msg_controllen = 0;
 	msg.msg_namelen = 0;
 
+	if (zc->addr) {
+		ret = move_addr_to_kernel(zc->addr, zc->addr_len, &address);
+		if (unlikely(ret < 0))
+			return ret;
+		msg.msg_name = (struct sockaddr *)&address;
+		msg.msg_namelen = zc->addr_len;
+	}
+
 	if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
 		ret = io_import_fixed(WRITE, &msg.msg_iter, req->imu,
 					(u64)(uintptr_t)zc->buf, zc->len);
@@ -992,14 +1000,6 @@ int io_sendzc(struct io_kiocb *req, unsigned int issue_flags)
 			return ret;
 	}
 
-	if (zc->addr) {
-		ret = move_addr_to_kernel(zc->addr, zc->addr_len, &address);
-		if (unlikely(ret < 0))
-			return ret;
-		msg.msg_name = (struct sockaddr *)&address;
-		msg.msg_namelen = zc->addr_len;
-	}
-
 	msg_flags = zc->msg_flags | MSG_ZEROCOPY;
 	if (issue_flags & IO_URING_F_NONBLOCK)
 		msg_flags |= MSG_DONTWAIT;
Signature · 1 line
2.37.0
#3 lore raw

PATCH 3/3 io_uring/notif: raise limit on notification slots

In reply to Pavel Begunkov

1024 notification slots is rather an arbitrary value, raise it up, everything is accounted to memcg.

---
 io_uring/notif.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/notif.h +1 -1
index 65f0b42f2555..80f6445e0c2b 100644
@@ -8,7 +8,7 @@
 #include "rsrc.h"
 
 #define IO_NOTIF_SPLICE_BATCH	32
-#define IORING_MAX_NOTIF_SLOTS (1U << 10)
+#define IORING_MAX_NOTIF_SLOTS	(1U << 15)
 
 struct io_notif_data {
 	struct file		*file;
Signature · 1 line
2.37.0
maintainer Applied
#4 lore raw
In reply to Pavel Begunkov
Quoted 8 lines · Pavel Begunkov

Just a random bunch of changes we need in 5.20

Pavel Begunkov (3):
io_uring/net: use right helpers for async recycle io_uring/net: improve zc addr import error handling io_uring/notif: raise limit on notification slots

[...]

Applied, thanks!

[1/3] io_uring/net: use right helpers for async recycle

      commit: 063604265f967e90901996a1b173fe6df582d350
[2/3] io_uring/net: improve zc addr import error handling
      commit: 86dc8f23bb1b68262ca5db890ec7177b2d074640
[3/3] io_uring/notif: raise limit on notification slots
      commit: 5993000dc6b31b927403cee65fbc5f9f070fa3e4

Best regards,

Signature · 1 line
Jens Axboe