Skip to content

Commit 0ba9c9e

Browse files
committed
io_uring: use TWA_SIGNAL for task_work uncondtionally
An earlier commit: b7db41c ("io_uring: fix regression with always ignoring signals in io_cqring_wait()") ensured that we didn't get stuck waiting for eventfd reads when it's registered with the io_uring ring for event notification, but we still have cases where the task can be waiting on other events in the kernel and need a bigger nudge to make forward progress. Or the task could be in the kernel and running, but on its way to blocking. This means that TWA_RESUME cannot reliably be used to ensure we make progress. Use TWA_SIGNAL unconditionally. Cc: [email protected] # v5.7+ Reported-by: Josef <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent f74441e commit 0ba9c9e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

fs/io_uring.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,22 +1710,22 @@ static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb)
17101710
{
17111711
struct task_struct *tsk = req->task;
17121712
struct io_ring_ctx *ctx = req->ctx;
1713-
int ret, notify = TWA_RESUME;
1713+
int ret, notify;
17141714

17151715
/*
1716-
* SQPOLL kernel thread doesn't need notification, just a wakeup.
1717-
* If we're not using an eventfd, then TWA_RESUME is always fine,
1718-
* as we won't have dependencies between request completions for
1719-
* other kernel wait conditions.
1716+
* SQPOLL kernel thread doesn't need notification, just a wakeup. For
1717+
* all other cases, use TWA_SIGNAL unconditionally to ensure we're
1718+
* processing task_work. There's no reliable way to tell if TWA_RESUME
1719+
* will do the job.
17201720
*/
1721-
if (ctx->flags & IORING_SETUP_SQPOLL)
1722-
notify = 0;
1723-
else if (ctx->cq_ev_fd)
1721+
notify = 0;
1722+
if (!(ctx->flags & IORING_SETUP_SQPOLL))
17241723
notify = TWA_SIGNAL;
17251724

17261725
ret = task_work_add(tsk, cb, notify);
17271726
if (!ret)
17281727
wake_up_process(tsk);
1728+
17291729
return ret;
17301730
}
17311731

0 commit comments

Comments
 (0)