Skip to content

Commit 8e3100f

Browse files
calebsanderaxboe
authored andcommitted
io_uring/net: only import send_zc buffer once
io_send_zc() guards its call to io_send_zc_import() with if (!done_io) in an attempt to avoid calling it redundantly on the same req. However, if the initial non-blocking issue returns -EAGAIN, done_io will stay 0. This causes the subsequent issue to unnecessarily re-import the buffer. Add an explicit flag "imported" to io_sr_msg to track if its buffer has already been imported. Clear the flag in io_send_zc_prep(). Call io_send_zc_import() and set the flag in io_send_zc() if it is unset. Signed-off-by: Caleb Sander Mateos <[email protected]> Fixes: 54cdcca ("io_uring/net: switch io_send() and io_send_zc() to using io_async_msghdr") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent ef49027 commit 8e3100f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

io_uring/net.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct io_sr_msg {
7777
/* initialised and used only by !msg send variants */
7878
u16 buf_group;
7979
bool retry;
80+
bool imported; /* only for io_send_zc */
8081
void __user *msg_control;
8182
/* used only for send zerocopy */
8283
struct io_kiocb *notif;
@@ -1306,6 +1307,7 @@ int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
13061307

13071308
zc->done_io = 0;
13081309
zc->retry = false;
1310+
zc->imported = false;
13091311
req->flags |= REQ_F_POLL_NO_LAZY;
13101312

13111313
if (unlikely(READ_ONCE(sqe->__pad2[0]) || READ_ONCE(sqe->addr3)))
@@ -1451,7 +1453,8 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
14511453
(zc->flags & IORING_RECVSEND_POLL_FIRST))
14521454
return -EAGAIN;
14531455

1454-
if (!zc->done_io) {
1456+
if (!zc->imported) {
1457+
zc->imported = true;
14551458
ret = io_send_zc_import(req, issue_flags);
14561459
if (unlikely(ret))
14571460
return ret;

0 commit comments

Comments
 (0)