public inbox for [email protected]
 help / color / mirror / Atom feed
* [RFC PATCH for-next] io_uring: assign ctx->ring_file and ctx->ring_fd early in io_uring_create()
@ 2020-09-13 13:04 Xiaoguang Wang
  0 siblings, 0 replies; only message in thread
From: Xiaoguang Wang @ 2020-09-13 13:04 UTC (permalink / raw)
  To: io-uring; +Cc: axboe, asml.silence, joseph.qi, Xiaoguang Wang

While testing the feature which supports multiple rings to share same poll
thread by specifying same cpu, fio often hangs in fio_ioring_getevents()
infinitely. After some investigations, I find it's because ctx->ring_file
is NULL, so io_sq_thread doest not submit this ctx's requests.

While ring initialization completes, IORING_SQ_NEED_WAKEUP will be not
set initially, app may already submit some reqs and the corresponding
io_sq_thread may already see these reqs, but will not submit them because
ring_file is NULL. Some apps just check IORING_SQ_NEED_WAKEUP beforce
submitting reqs, for example, fio just checks it in fio_ioring_commit()
and will not check it in fio_ioring_getevents(), then fio will hang
forever. To fix this issue, we assign ctx->ring_file and ctx->ring_fd
early in io_uring_create().

Signed-off-by: Xiaoguang Wang <[email protected]>
---
 fs/io_uring.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 321a430ff3f7..5ddb2cddc695 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -9034,6 +9034,11 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p,
 		goto err;
 	}
 
+	if (p->flags & IORING_SETUP_SQPOLL) {
+		ctx->ring_fd = fd;
+		ctx->ring_file = file;
+	}
+
 	ret = io_sq_offload_create(ctx, p);
 	if (ret)
 		goto err;
-- 
2.17.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-13 13:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-13 13:04 [RFC PATCH for-next] io_uring: assign ctx->ring_file and ctx->ring_fd early in io_uring_create() Xiaoguang Wang

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