Skip to content

Commit 108893d

Browse files
isilenceaxboe
authored andcommitted
io_uring/net: fix notif cqe reordering
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. Cc: [email protected] Fixes: 53bdc88 ("io_uring/notif: order notif vs send CQEs") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/0031f3a00d492e814a4a0935a2029a46d9c9ba06.1664486545.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 6f10ae8 commit 108893d

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

io_uring/net.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,14 @@ int io_send_zc(struct io_kiocb *req, unsigned int issue_flags)
11271127
else if (zc->done_io)
11281128
ret = zc->done_io;
11291129

1130-
io_notif_flush(zc->notif);
1131-
req->flags &= ~REQ_F_NEED_CLEANUP;
1130+
/*
1131+
* If we're in io-wq we can't rely on tw ordering guarantees, defer
1132+
* flushing notif to io_send_zc_cleanup()
1133+
*/
1134+
if (!(issue_flags & IO_URING_F_UNLOCKED)) {
1135+
io_notif_flush(zc->notif);
1136+
req->flags &= ~REQ_F_NEED_CLEANUP;
1137+
}
11321138
io_req_set_res(req, ret, IORING_CQE_F_MORE);
11331139
return IOU_OK;
11341140
}
@@ -1182,17 +1188,25 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags)
11821188
req_set_fail(req);
11831189
}
11841190
/* fast path, check for non-NULL to avoid function call */
1185-
if (kmsg->free_iov)
1191+
if (kmsg->free_iov) {
11861192
kfree(kmsg->free_iov);
1193+
kmsg->free_iov = NULL;
1194+
}
11871195

11881196
io_netmsg_recycle(req, issue_flags);
11891197
if (ret >= 0)
11901198
ret += sr->done_io;
11911199
else if (sr->done_io)
11921200
ret = sr->done_io;
11931201

1194-
io_notif_flush(sr->notif);
1195-
req->flags &= ~REQ_F_NEED_CLEANUP;
1202+
/*
1203+
* If we're in io-wq we can't rely on tw ordering guarantees, defer
1204+
* flushing notif to io_send_zc_cleanup()
1205+
*/
1206+
if (!(issue_flags & IO_URING_F_UNLOCKED)) {
1207+
io_notif_flush(sr->notif);
1208+
req->flags &= ~REQ_F_NEED_CLEANUP;
1209+
}
11961210
io_req_set_res(req, ret, IORING_CQE_F_MORE);
11971211
return IOU_OK;
11981212
}

0 commit comments

Comments
 (0)