io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] io_uring: mitigate unlikely iopoll lag
@ 2021-07-08 12:37 Pavel Begunkov
  2021-07-08 20:08 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-07-08 12:37 UTC (permalink / raw)
  To: Jens Axboe, io-uring

We have requests like IORING_OP_FILES_UPDATE that don't go through
->iopoll_list but get completed in place under ->uring_lock, and so
after dropping the lock io_iopoll_check() should expect that some CQEs
might have get completed in a meanwhile.

Currently such events won't be accounted in @nr_events, and the loop
will continue to poll even if there is enough of CQEs. It shouldn't be a
problem as it's not likely to happen and so, but not nice either. Just
return earlier in this case, it should be enough.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 fs/io_uring.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 8f2a66903f5a..7167c61c6d1b 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2356,11 +2356,15 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, long min)
 		 * very same mutex.
 		 */
 		if (list_empty(&ctx->iopoll_list)) {
+			u32 tail = ctx->cached_cq_tail;
+
 			mutex_unlock(&ctx->uring_lock);
 			io_run_task_work();
 			mutex_lock(&ctx->uring_lock);
 
-			if (list_empty(&ctx->iopoll_list))
+			/* some requests don't go through iopoll_list */
+			if (tail != ctx->cached_cq_tail ||
+			    list_empty(&ctx->iopoll_list))
 				break;
 		}
 		ret = io_do_iopoll(ctx, &nr_events, min);
-- 
2.32.0


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

* Re: [PATCH 1/1] io_uring: mitigate unlikely iopoll lag
  2021-07-08 12:37 [PATCH 1/1] io_uring: mitigate unlikely iopoll lag Pavel Begunkov
@ 2021-07-08 20:08 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-07-08 20:08 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 7/8/21 6:37 AM, Pavel Begunkov wrote:
> We have requests like IORING_OP_FILES_UPDATE that don't go through
> ->iopoll_list but get completed in place under ->uring_lock, and so
> after dropping the lock io_iopoll_check() should expect that some CQEs
> might have get completed in a meanwhile.
> 
> Currently such events won't be accounted in @nr_events, and the loop
> will continue to poll even if there is enough of CQEs. It shouldn't be a
> problem as it's not likely to happen and so, but not nice either. Just
> return earlier in this case, it should be enough.

Applied, thanks.

-- 
Jens Axboe


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

end of thread, other threads:[~2021-07-08 20:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 12:37 [PATCH 1/1] io_uring: mitigate unlikely iopoll lag Pavel Begunkov
2021-07-08 20:08 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).