public inbox for [email protected]
 help / color / mirror / Atom feed
From: Xiaoguang Wang <[email protected]>
To: [email protected]
Cc: [email protected], [email protected],
	[email protected],
	Xiaoguang Wang <[email protected]>
Subject: [RFC PATCH for-next] io_uring: assign ctx->ring_file and ctx->ring_fd early in io_uring_create()
Date: Sun, 13 Sep 2020 21:04:26 +0800	[thread overview]
Message-ID: <[email protected]> (raw)

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


                 reply	other threads:[~2020-09-13 13:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200913130426.6273-1-xiaoguang.wang@linux.alibaba.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox