Skip to content

Commit bd2703b

Browse files
isilenceaxboe
authored andcommitted
io_uring: don't touch sqd->thread off tw add
With IORING_SETUP_SQPOLL all requests are created by the SQPOLL task, which means that req->task should always match sqd->thread. Since accesses to sqd->thread should be separately protected, use req->task in io_req_normal_work_add() instead. Note, in the eyes of io_req_normal_work_add(), the SQPOLL task struct is always pinned and alive, and sqd->thread can either be the task or NULL. It's only problematic if the compiler decides to reload the value after the null check, which is not so likely. Cc: stable@vger.kernel.org Cc: Bui Quang Minh <minhquangbui99@gmail.com> Reported-by: lizetao <lizetao1@huawei.com> Fixes: 78f9b61 ("io_uring: wake SQPOLL task when task_work is added to an empty queue") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/1cbbe72cf32c45a8fee96026463024cd8564a7d7.1736541357.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 4b7cfa8 commit bd2703b

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

io_uring/io_uring.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,10 +1226,7 @@ static void io_req_normal_work_add(struct io_kiocb *req)
12261226

12271227
/* SQPOLL doesn't need the task_work added, it'll run it itself */
12281228
if (ctx->flags & IORING_SETUP_SQPOLL) {
1229-
struct io_sq_data *sqd = ctx->sq_data;
1230-
1231-
if (sqd->thread)
1232-
__set_notify_signal(sqd->thread);
1229+
__set_notify_signal(tctx->task);
12331230
return;
12341231
}
12351232

0 commit comments

Comments
 (0)