Skip to content

Commit

Permalink
io_uring: don't touch sqd->thread off tw add
Browse files Browse the repository at this point in the history
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: [email protected]
Cc: Bui Quang Minh <[email protected]>
Reported-by: lizetao <[email protected]>
Fixes: 78f9b61 ("io_uring: wake SQPOLL task when task_work is added to an empty queue")
Signed-off-by: Pavel Begunkov <[email protected]>
Link: https://lore.kernel.org/r/1cbbe72cf32c45a8fee96026463024cd8564a7d7.1736541357.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
isilence authored and jhanger-dev committed Jan 20, 2025
1 parent 0fc27d7 commit 3360d8b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions io_uring/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1226,10 +1226,7 @@ static void io_req_normal_work_add(struct io_kiocb *req)

/* SQPOLL doesn't need the task_work added, it'll run it itself */
if (ctx->flags & IORING_SETUP_SQPOLL) {
struct io_sq_data *sqd = ctx->sq_data;

if (sqd->thread)
__set_notify_signal(sqd->thread);
__set_notify_signal(tctx->task);
return;
}

Expand Down

0 comments on commit 3360d8b

Please sign in to comment.