Skip to content

Commit 77e443a

Browse files
isilenceaxboe
authored andcommitted
io_uring: never run tw and fallback in parallel
Once we fallback a tw we want all requests to that task to be given to the fallback wq so we dont run it in parallel with the last, i.e. post PF_EXITING, tw run of the task. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/96f4987265c4312f376f206511c6af3e77aaf5ac.1670384893.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent d34b1b0 commit 77e443a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

io_uring/io_uring.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ static void io_clean_op(struct io_kiocb *req);
149149
static void io_queue_sqe(struct io_kiocb *req);
150150
static void io_move_task_work_from_local(struct io_ring_ctx *ctx);
151151
static void __io_submit_flush_completions(struct io_ring_ctx *ctx);
152+
static __cold void io_fallback_tw(struct io_uring_task *tctx);
152153

153154
static struct kmem_cache *req_cachep;
154155

@@ -1149,10 +1150,17 @@ void tctx_task_work(struct callback_head *cb)
11491150
struct io_uring_task *tctx = container_of(cb, struct io_uring_task,
11501151
task_work);
11511152
struct llist_node fake = {};
1152-
struct llist_node *node = io_llist_xchg(&tctx->task_list, &fake);
1153+
struct llist_node *node;
11531154
unsigned int loops = 1;
1154-
unsigned int count = handle_tw_list(node, &ctx, &uring_locked, NULL);
1155+
unsigned int count;
1156+
1157+
if (unlikely(current->flags & PF_EXITING)) {
1158+
io_fallback_tw(tctx);
1159+
return;
1160+
}
11551161

1162+
node = io_llist_xchg(&tctx->task_list, &fake);
1163+
count = handle_tw_list(node, &ctx, &uring_locked, NULL);
11561164
node = io_llist_cmpxchg(&tctx->task_list, &fake, NULL);
11571165
while (node != &fake) {
11581166
loops++;

0 commit comments

Comments
 (0)