public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH v2] io_uring: use TWA_SIGNAL for task_work if the task isn't running
@ 2020-08-07 16:55 Jens Axboe
  2020-08-07 18:00 ` Jann Horn
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2020-08-07 16:55 UTC (permalink / raw)
  To: io-uring

An earlier commit:

b7db41c9e03b ("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 a gap where the task can be waiting on other events in the kernel
and need a bigger nudge to make forward progress.

Ensure that we use signaled notifications for a task that isn't currently
running, to be certain the work is seen and processed immediately.

Cc: [email protected] # v5.7+
Reported-by: Josef <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>

---

This isn't perfect, as it'll use TWA_SIGNAL even for cases where we
don't absolutely need it (like task waiting for completions in
io_cqring_wait()), but we don't have a good way to tell right now. We
can probably improve on this in the future, for now I think this is the
best solution.

diff --git a/fs/io_uring.c b/fs/io_uring.c
index e9b27cdaa735..b4300a61f231 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1720,7 +1720,7 @@ static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb)
 	 */
 	if (ctx->flags & IORING_SETUP_SQPOLL)
 		notify = 0;
-	else if (ctx->cq_ev_fd)
+	else if (ctx->cq_ev_fd || (tsk->state != TASK_RUNNING))
 		notify = TWA_SIGNAL;
 
 	ret = task_work_add(tsk, cb, notify);

-- 
Jens Axboe


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-07 22:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-07 16:55 [PATCH v2] io_uring: use TWA_SIGNAL for task_work if the task isn't running Jens Axboe
2020-08-07 18:00 ` Jann Horn
2020-08-07 21:50   ` Jens Axboe
2020-08-07 22:11     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox