public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH 1/1] io_uring: don't wait when under-submitting
@ 2019-12-13  7:51 Pavel Begunkov
  2019-12-13 18:22 ` Jens Axboe
  2019-12-14 14:31 ` [PATCH v2] " Pavel Begunkov
  0 siblings, 2 replies; 16+ messages in thread
From: Pavel Begunkov @ 2019-12-13  7:51 UTC (permalink / raw)
  To: Jens Axboe, io-uring, linux-kernel

There is no reliable way to submit and wait in a single syscall, as
io_submit_sqes() may under-consume sqes (in case of an early error).
Then it will wait for not-yet-submitted requests, deadlocking the user
in most cases.

Don't wait/poll if can't submit all sqes, and return -EAGAIN

Signed-off-by: Pavel Begunkov <[email protected]>
---

I wonder, why it doesn't return 2 error codes for submission and waiting
separately? It's a bit puzzling figuring out what to return. I guess the
same with the userspace side.

 fs/io_uring.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 42de210be631..82152ea13fe2 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -4877,6 +4877,11 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
 		submitted = io_submit_sqes(ctx, to_submit, f.file, fd,
 					   &cur_mm, false);
 		mutex_unlock(&ctx->uring_lock);
+
+		if (submitted != to_submit) {
+			submitted = -EAGAIN;
+			goto out;
+		}
 	}
 	if (flags & IORING_ENTER_GETEVENTS) {
 		unsigned nr_events = 0;
@@ -4890,6 +4895,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
 		}
 	}
 
+out:
 	percpu_ref_put(&ctx->refs);
 out_fput:
 	fdput(f);
-- 
2.24.0


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

end of thread, other threads:[~2019-12-16 16:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-13  7:51 [PATCH 1/1] io_uring: don't wait when under-submitting Pavel Begunkov
2019-12-13 18:22 ` Jens Axboe
2019-12-13 18:32   ` Jens Axboe
2019-12-13 21:32     ` Pavel Begunkov
2019-12-13 21:48       ` Jens Axboe
2019-12-14 14:31 ` [PATCH v2] " Pavel Begunkov
2019-12-14 14:39   ` Jens Axboe
2019-12-14 14:44     ` Pavel Begunkov
2019-12-14 14:53   ` [PATCH v3] " Pavel Begunkov
2019-12-14 18:43     ` Jens Axboe
2019-12-15  5:42       ` Jens Axboe
2019-12-15 15:48         ` Pavel Begunkov
2019-12-15 21:33           ` Jens Axboe
2019-12-16 16:31             ` [PATCH v4] " Pavel Begunkov
2019-12-16 16:47             ` [PATCH v3] " Pavel Begunkov
2019-12-16 16:51               ` Jens Axboe

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