Skip to content

Commit 7d481e0

Browse files
isilenceaxboe
authored andcommitted
io_uring/rsrc: fix DEFER_TASKRUN rsrc quiesce
For io_rsrc_ref_quiesce() to progress it should execute all task_work items, including deferred ones. However, currently nobody would wake us, and so let's set ctx->cq_wait_nr, so io_req_local_work_add() would wake us up. Fixes: c0e0d6b ("io_uring: add IORING_SETUP_DEFER_TASKRUN") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/f1a90d1bc5ebf096475b018fed52e54f3b89d4af.1681395792.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 4ea15b5 commit 7d481e0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

io_uring/rsrc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data,
273273
if (io_put_rsrc_data_ref(data))
274274
return 0;
275275

276+
if (ctx->flags & IORING_SETUP_DEFER_TASKRUN) {
277+
atomic_set(&ctx->cq_wait_nr, 1);
278+
smp_mb();
279+
}
280+
276281
data->quiesce = true;
277282
do {
278283
prepare_to_wait(&ctx->rsrc_quiesce_wq, &we, TASK_INTERRUPTIBLE);
@@ -298,6 +303,10 @@ __cold static int io_rsrc_ref_quiesce(struct io_rsrc_data *data,
298303

299304
finish_wait(&ctx->rsrc_quiesce_wq, &we);
300305
data->quiesce = false;
306+
if (ctx->flags & IORING_SETUP_DEFER_TASKRUN) {
307+
atomic_set(&ctx->cq_wait_nr, 0);
308+
smp_mb();
309+
}
301310
return ret;
302311
}
303312

0 commit comments

Comments
 (0)