Skip to contentSkip to conversation

net fixes

PATCH Applied Pavel Begunkov 2 participants 7 messages Sep 29, 2022 – Oct 6, 2022 io_uring

lore
Share & tools
lore
#0 lore raw

cover net fixes

two extra io_uring/net fixes

Pavel Begunkov (2):
io_uring/net: don't update msg_name if not provided io_uring/net: fix notif cqe reordering

 io_uring/net.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
Signature · 1 line
2.37.2
#1 lore raw

PATCH 1/2 io_uring/net: don't update msg_name if not provided

io_sendmsg_copy_hdr() may clear msg->msg_name if the userspace didn't provide it, we should retain NULL in this case.

---
 io_uring/net.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
io_uring/net.c +2 -1
index 9ada9da02d04..604eac5f7a34 100644
@@ -164,7 +164,8 @@ static int io_setup_async_msg(struct io_kiocb *req,
 	}
 	req->flags |= REQ_F_NEED_CLEANUP;
 	memcpy(async_msg, kmsg, sizeof(*kmsg));
-	async_msg->msg.msg_name = &async_msg->addr;
+	if (async_msg->msg.msg_name)
+		async_msg->msg.msg_name = &async_msg->addr;
 	/* if were using fast_iov, set it to the new one */
 	if (!kmsg->free_iov) {
 		size_t fast_idx = kmsg->msg.msg_iter.iov - kmsg->fast_iov;
Signature · 1 line
2.37.2
#2 lore raw

PATCH 2/2 io_uring/net: fix notif cqe reordering

In reply to Pavel Begunkov

send zc is not restricted to !IO_URING_F_UNLOCKED anymore and so we can't use task-tw ordering trick to order notification cqes with requests completions. In this case leave it alone and let io_send_zc_cleanup() flush it.

Fixes 53bdc88aac9a2 ("io_uring/notif: order notif vs send CQEs")
---
 io_uring/net.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
io_uring/net.c +19 -5
index 604eac5f7a34..caa6a803cb72 100644
@@ -1127,8 +1127,14 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
 	else if (zc->done_io)
 		ret = zc->done_io;
 
-	io_notif_flush(zc->notif);
-	req->flags &= ~REQ_F_NEED_CLEANUP;
+	/*
+	 * If we're in io-wq we can't rely on tw ordering guarantees, defer
+	 * flushing notif to io_send_zc_cleanup()
+	 */
+	if (!(issue_flags & IO_URING_F_UNLOCKED)) {
+		io_notif_flush(zc->notif);
+		req->flags &= ~REQ_F_NEED_CLEANUP;
+	}
 	io_req_set_res(req, ret, IORING_CQE_F_MORE);
 	return IOU_OK;
 }
@@ -1182,8 +1188,10 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)
 		req_set_fail(req);
 	}
 	/* fast path, check for non-NULL to avoid function call */
-	if (kmsg->free_iov)
+	if (kmsg->free_iov) {
 		kfree(kmsg->free_iov);
+		kmsg->free_iov = NULL;
+	}
 
 	io_netmsg_recycle(req, issue_flags);
 	if (ret >= 0)
@@ -1191,8 +1199,14 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)
 	else if (sr->done_io)
 		ret = sr->done_io;
 
-	io_notif_flush(sr->notif);
-	req->flags &= ~REQ_F_NEED_CLEANUP;
+	/*
+	 * If we're in io-wq we can't rely on tw ordering guarantees, defer
+	 * flushing notif to io_send_zc_cleanup()
+	 */
+	if (!(issue_flags & IO_URING_F_UNLOCKED)) {
+		io_notif_flush(sr->notif);
+		req->flags &= ~REQ_F_NEED_CLEANUP;
+	}
 	io_req_set_res(req, ret, IORING_CQE_F_MORE);
 	return IOU_OK;
 }
Signature · 1 line
2.37.2
maintainer Applied
#3 lore raw
In reply to Pavel Begunkov
Quoted 10 lines · Pavel Begunkov

two extra io_uring/net fixes

Pavel Begunkov (2):
io_uring/net: don't update msg_name if not provided io_uring/net: fix notif cqe reordering

io_uring/net.c | 27 +++++++++++++++++++++------

 1 file changed, 21 insertions(+), 6 deletions(-)

[...]

Applied, thanks!

[1/2] io_uring/net: don't update msg_name if not provided

      commit: 6f10ae8a155446248055c7ddd480ef40139af788
[2/2] io_uring/net: fix notif cqe reordering
      commit: 108893ddcc4d3aa0a4a02aeb02d478e997001227

Best regards,

Signature · 1 line
Jens Axboe
#4 lore raw
Quoted 7 lines · Jens Axboe
Quoted 6 lines · Pavel Begunkov

two extra io_uring/net fixes

Pavel Begunkov (2):
io_uring/net: don't update msg_name if not provided io_uring/net: fix notif cqe reordering

Quoted 6 lines
Quoted 4 lines

io_uring/net.c | 27 +++++++++++++++++++++------

  1 file changed, 21 insertions(+), 6 deletions(-)

[...]

Applied, thanks!

Hmm, where did these go? Don't see neither in for-6.1 nor 6.1-late

Quoted 6 lines

[1/2] io_uring/net: don't update msg_name if not provided

       commit: 6f10ae8a155446248055c7ddd480ef40139af788
[2/2] io_uring/net: fix notif cqe reordering
       commit: 108893ddcc4d3aa0a4a02aeb02d478e997001227

Best regards,

Signature · 1 line
Pavel Begunkov
maintainer
#5 lore raw
Quoted 11 lines · Pavel Begunkov
Quoted 10 lines · Jens Axboe
Quoted 9 lines · Pavel Begunkov

two extra io_uring/net fixes

Pavel Begunkov (2):
   io_uring/net: don't update msg_name if not provided io_uring/net: fix notif cqe reordering

io_uring/net.c | 27 +++++++++++++++++++++------

  1 file changed, 21 insertions(+), 6 deletions(-)
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

[...]

Applied, thanks!

Hmm, where did these go? Don't see neither in for-6.1 nor 6.1-late

They are in for-6.1/io_uring with the shas listed here too:

Quoted 4 lines
Quoted 4 lines

[1/2] io_uring/net: don't update msg_name if not provided
       commit: 6f10ae8a155446248055c7ddd480ef40139af788 [2/2] io_uring/net: fix notif cqe reordering
       commit: 108893ddcc4d3aa0a4a02aeb02d478e997001227

Top of tree, in fact:

https://git.kernel.dk/cgit/linux-block/log/?h=for-6.1/io_uring

Signature · 1 line
Jens Axboe
#6 lore raw
Quoted 21 lines · Jens Axboe
Quoted 11 lines · Pavel Begunkov
Quoted 10 lines · Jens Axboe
Quoted 9 lines · Pavel Begunkov

two extra io_uring/net fixes

Pavel Begunkov (2):
   io_uring/net: don't update msg_name if not provided io_uring/net: fix notif cqe reordering

io_uring/net.c | 27 +++++++++++++++++++++------

   1 file changed, 21 insertions(+), 6 deletions(-)
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

[...]

Applied, thanks!

Hmm, where did these go? Don't see neither in for-6.1 nor 6.1-late

They are in for-6.1/io_uring with the shas listed here too:

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

[1/2] io_uring/net: don't update msg_name if not provided
       commit: 6f10ae8a155446248055c7ddd480ef40139af788
[2/2] io_uring/net: fix notif cqe reordering
       commit: 108893ddcc4d3aa0a4a02aeb02d478e997001227

Top of tree, in fact:

https://git.kernel.dk/cgit/linux-block/log/?h=for-6.1/io_uring

See now, thanks, seems messed up pulling branches

Signature · 1 line
Pavel Begunkov