Skip to content

Commit 53bdc88

Browse files
isilenceaxboe
authored andcommitted
io_uring/notif: order notif vs send CQEs
Currently, there is no ordering between notification CQEs and completions of the send flushing it, this quite complicates the userspace, especially since we don't flush notification when the send(+flush) request fails, i.e. there will be only one CQE. What we can do is to make sure that notification completions come only after sends. The easiest way to achieve this is to not try to complete a notification inline from io_sendzc() but defer it to task_work, considering that io-wq sendzc is disallowed CQEs will be naturally ordered because task_works will only be executed after we're done with submission and so inline completion. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/cddfd1c2bf91f22b9fe08e13b7dffdd8f858a151.1661342812.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 986e263 commit 53bdc88

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

io_uring/notif.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ void io_notif_slot_flush(struct io_notif_slot *slot)
8181
slot->notif = NULL;
8282

8383
/* drop slot's master ref */
84-
if (refcount_dec_and_test(&nd->uarg.refcnt))
85-
io_notif_complete(notif);
84+
if (refcount_dec_and_test(&nd->uarg.refcnt)) {
85+
notif->io_task_work.func = __io_notif_complete_tw;
86+
io_req_task_work_add(notif);
87+
}
8688
}
8789

8890
__cold int io_notif_unregister(struct io_ring_ctx *ctx)

0 commit comments

Comments
 (0)