All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] io_uring/net: fix zc fixed buf lifetime
@ 2022-09-16 22:22 Pavel Begunkov
  2022-09-17 10:27 ` Stefan Metzmacher
  2022-09-18 11:10 ` Jens Axboe
  0 siblings, 2 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-09-16 22:22 UTC (permalink / raw)
  To: io-uring; +Cc: Jens Axboe, asml.silence

Notifications usually outlive requests, so we need to pin buffers with
it by assigning a rsrc to it instead of the request.

Fixed: b48c312be05e8 ("io_uring/net: simplify zerocopy send user API")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/net.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/io_uring/net.c b/io_uring/net.c
index e9efed40cf3d..60e392f7f2dc 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -905,6 +905,13 @@ int io_sendzc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 	if (zc->flags & ~(IORING_RECVSEND_POLL_FIRST |
 			  IORING_RECVSEND_FIXED_BUF))
 		return -EINVAL;
+	notif = zc->notif = io_alloc_notif(ctx);
+	if (!notif)
+		return -ENOMEM;
+	notif->cqe.user_data = req->cqe.user_data;
+	notif->cqe.res = 0;
+	notif->cqe.flags = IORING_CQE_F_NOTIF;
+	req->flags |= REQ_F_NEED_CLEANUP;
 	if (zc->flags & IORING_RECVSEND_FIXED_BUF) {
 		unsigned idx = READ_ONCE(sqe->buf_index);
 
@@ -912,15 +919,8 @@ int io_sendzc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
 			return -EFAULT;
 		idx = array_index_nospec(idx, ctx->nr_user_bufs);
 		req->imu = READ_ONCE(ctx->user_bufs[idx]);
-		io_req_set_rsrc_node(req, ctx, 0);
+		io_req_set_rsrc_node(notif, ctx, 0);
 	}
-	notif = zc->notif = io_alloc_notif(ctx);
-	if (!notif)
-		return -ENOMEM;
-	notif->cqe.user_data = req->cqe.user_data;
-	notif->cqe.res = 0;
-	notif->cqe.flags = IORING_CQE_F_NOTIF;
-	req->flags |= REQ_F_NEED_CLEANUP;
 
 	zc->buf = u64_to_user_ptr(READ_ONCE(sqe->addr));
 	zc->len = READ_ONCE(sqe->len);
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] io_uring/net: fix zc fixed buf lifetime
  2022-09-16 22:22 [PATCH 1/1] io_uring/net: fix zc fixed buf lifetime Pavel Begunkov
@ 2022-09-17 10:27 ` Stefan Metzmacher
  2022-09-17 11:58   ` Jens Axboe
  2022-09-18 11:10 ` Jens Axboe
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Metzmacher @ 2022-09-17 10:27 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring; +Cc: Jens Axboe

Am 17.09.22 um 00:22 schrieb Pavel Begunkov:
> Notifications usually outlive requests, so we need to pin buffers with
> it by assigning a rsrc to it instead of the request.
> 
> Fixed: b48c312be05e8 ("io_uring/net: simplify zerocopy send user API")
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>

Looks good to me :-)

metze

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] io_uring/net: fix zc fixed buf lifetime
  2022-09-17 10:27 ` Stefan Metzmacher
@ 2022-09-17 11:58   ` Jens Axboe
  2022-09-18  9:29     ` Stefan Metzmacher
  0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2022-09-17 11:58 UTC (permalink / raw)
  To: Stefan Metzmacher, Pavel Begunkov, io-uring

On 9/17/22 4:27 AM, Stefan Metzmacher wrote:
> Am 17.09.22 um 00:22 schrieb Pavel Begunkov:
>> Notifications usually outlive requests, so we need to pin buffers with
>> it by assigning a rsrc to it instead of the request.
>>
>> Fixed: b48c312be05e8 ("io_uring/net: simplify zerocopy send user API")
>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> 
> Looks good to me :-)

Can I turn that into an acked-by or reviewed-by?

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] io_uring/net: fix zc fixed buf lifetime
  2022-09-17 11:58   ` Jens Axboe
@ 2022-09-18  9:29     ` Stefan Metzmacher
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Metzmacher @ 2022-09-18  9:29 UTC (permalink / raw)
  To: Jens Axboe, Pavel Begunkov, io-uring

Am 17.09.22 um 13:58 schrieb Jens Axboe:
> On 9/17/22 4:27 AM, Stefan Metzmacher wrote:
>> Am 17.09.22 um 00:22 schrieb Pavel Begunkov:
>>> Notifications usually outlive requests, so we need to pin buffers with
>>> it by assigning a rsrc to it instead of the request.
>>>
>>> Fixed: b48c312be05e8 ("io_uring/net: simplify zerocopy send user API")
>>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>>
>> Looks good to me :-)
> 
> Can I turn that into an acked-by or reviewed-by?

reviewed-by is fine.

metze


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/1] io_uring/net: fix zc fixed buf lifetime
  2022-09-16 22:22 [PATCH 1/1] io_uring/net: fix zc fixed buf lifetime Pavel Begunkov
  2022-09-17 10:27 ` Stefan Metzmacher
@ 2022-09-18 11:10 ` Jens Axboe
  1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-09-18 11:10 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On Fri, 16 Sep 2022 23:22:57 +0100, Pavel Begunkov wrote:
> Notifications usually outlive requests, so we need to pin buffers with
> it by assigning a rsrc to it instead of the request.
> 
> 

Applied, thanks!

[1/1] io_uring/net: fix zc fixed buf lifetime
      commit: e3366e0234971a09f0e16f0e6fa16f4cbae45e47

Best regards,
-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-18 11:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 22:22 [PATCH 1/1] io_uring/net: fix zc fixed buf lifetime Pavel Begunkov
2022-09-17 10:27 ` Stefan Metzmacher
2022-09-17 11:58   ` Jens Axboe
2022-09-18  9:29     ` Stefan Metzmacher
2022-09-18 11:10 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.