From: Pavel Begunkov <asml.silence@gmail.com>
To: "Bhatia, Sumeet" <sumee@amazon.com>,
"io-uring@vger.kernel.org" <io-uring@vger.kernel.org>
Cc: "Hegde, Pramod" <phegde@amazon.com>
Subject: Re: Is it safe to submit and reap IOs in different threads?
Date: Thu, 7 May 2020 11:21:01 +0300 [thread overview]
Message-ID: <4a364d95-d80e-979e-dc18-c17e6b2e4e3c@gmail.com> (raw)
In-Reply-To: <1588806165324.88604@amazon.com>
On 07/05/2020 02:02, Bhatia, Sumeet wrote:
> Hello,
>
> My application has a thread per disk (aka producer_thread) that generates disk operations. I have io-uring context per disk to ensure iouring submissions are from a single thread.
>
> producer_thread executes only if new disk operations are to be submitted else it yields. It'll be significant code change to modify this behavior. For this reason I spin up a new thread (aka consumer thread) per io-uring context to reap IO completions.
>
> My reading of fs/io_uring.c suggests it is safe to submit IOs from producer_thread and reap IOs from consumer_thread. My prototype based on liburing (Ref: https://pastebin.com/6u2FZB0D) works fine too.
>
> I would like to get your thoughts on whether this approach is indeed safe or am I overlooking any race condition?
Shortly, if you don't mix up submissions and completions, it's safe. There is
only pitfall I found in liburing -- you shouldn't pass a timeout in wait
functions (e.g. io_uring_wait_cqes()), which would do submission.
Also take a look:
https://github.com/axboe/liburing/issues/108#issuecomment-619616721
--
Pavel Begunkov
prev parent reply other threads:[~2020-05-07 8:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-06 23:02 Is it safe to submit and reap IOs in different threads? Bhatia, Sumeet
2020-05-07 8:21 ` Pavel Begunkov [this message]
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=4a364d95-d80e-979e-dc18-c17e6b2e4e3c@gmail.com \
--to=asml.silence@gmail.com \
--cc=io-uring@vger.kernel.org \
--cc=phegde@amazon.com \
--cc=sumee@amazon.com \
/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