io_uring: use TWA_SIGNAL for task_work uncondtionally

An earlier commit:

b7db41c9e0 ("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: stable@vger.kernel.org # v5.7+
Reported-by: Josef <josef.grieb@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Jens Axboe 2020-08-06 19:41:50 -06:00
Родитель f74441e631
Коммит 0ba9c9edcd
1 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -1710,22 +1710,22 @@ static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb)
{ {
struct task_struct *tsk = req->task; struct task_struct *tsk = req->task;
struct io_ring_ctx *ctx = req->ctx; struct io_ring_ctx *ctx = req->ctx;
int ret, notify = TWA_RESUME; int ret, notify;
/* /*
* SQPOLL kernel thread doesn't need notification, just a wakeup. * SQPOLL kernel thread doesn't need notification, just a wakeup. For
* If we're not using an eventfd, then TWA_RESUME is always fine, * all other cases, use TWA_SIGNAL unconditionally to ensure we're
* as we won't have dependencies between request completions for * processing task_work. There's no reliable way to tell if TWA_RESUME
* other kernel wait conditions. * will do the job.
*/ */
if (ctx->flags & IORING_SETUP_SQPOLL) notify = 0;
notify = 0; if (!(ctx->flags & IORING_SETUP_SQPOLL))
else if (ctx->cq_ev_fd)
notify = TWA_SIGNAL; notify = TWA_SIGNAL;
ret = task_work_add(tsk, cb, notify); ret = task_work_add(tsk, cb, notify);
if (!ret) if (!ret)
wake_up_process(tsk); wake_up_process(tsk);
return ret; return ret;
} }