Skip to content

Commit

Permalink
io_uring: wake SQPOLL task when task_work is added to an empty queue
Browse files Browse the repository at this point in the history
If there's no current work on the list, we still need to potentially
wake the SQPOLL task if it is sleeping. This is ordered with the
wait queue addition in sqpoll, which adds to the wait queue before
checking for pending work items.

Fixes: af5d68f ("io_uring/sqpoll: manage task_work privately")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Jens Axboe committed Feb 14, 2024
1 parent 428f138 commit 78f9b61
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion io_uring/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1370,8 +1370,13 @@ static void io_req_normal_work_add(struct io_kiocb *req)
atomic_or(IORING_SQ_TASKRUN, &ctx->rings->sq_flags);

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

if (wq_has_sleeper(&sqd->wait))
wake_up(&sqd->wait);
return;
}

if (likely(!task_work_add(req->task, &tctx->task_work, ctx->notify_method)))
return;
Expand Down

0 comments on commit 78f9b61

Please sign in to comment.