Skip to content

Commit c8d8fc3

Browse files
committed
io_uring/sqpoll: use the correct check for pending task_work
A previous commit moved to using just the private task_work list for SQPOLL, but it neglected to update the check for whether we have pending task_work. Normally this is fine as we'll attempt to run it unconditionally, but if we race with going to sleep AND task_work being added, then we certainly need the right check here. Fixes: af5d68f ("io_uring/sqpoll: manage task_work privately") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 78f9b61 commit c8d8fc3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

io_uring/sqpoll.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ static unsigned int io_sq_tw(struct llist_node **retry_list, int max_entries)
246246
return count;
247247
}
248248

249+
static bool io_sq_tw_pending(struct llist_node *retry_list)
250+
{
251+
struct io_uring_task *tctx = current->io_uring;
252+
253+
return retry_list || !llist_empty(&tctx->task_list);
254+
}
255+
249256
static int io_sq_thread(void *data)
250257
{
251258
struct llist_node *retry_list = NULL;
@@ -301,7 +308,7 @@ static int io_sq_thread(void *data)
301308
}
302309

303310
prepare_to_wait(&sqd->wait, &wait, TASK_INTERRUPTIBLE);
304-
if (!io_sqd_events_pending(sqd) && !task_work_pending(current)) {
311+
if (!io_sqd_events_pending(sqd) && !io_sq_tw_pending(retry_list)) {
305312
bool needs_sched = true;
306313

307314
list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) {

0 commit comments

Comments
 (0)