From: Pavel Begunkov <[email protected]>
To: Olivier Langlois <[email protected]>,
Jens Axboe <[email protected]>,
[email protected], [email protected]
Subject: Re: [PATCH] io_uring: reduce latency by reissueing the operation
Date: Thu, 10 Jun 2021 10:03:59 +0100 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
On 6/9/21 11:08 PM, Olivier Langlois wrote:
> It is quite frequent that when an operation fails and returns EAGAIN,
> the data becomes available between that failure and the call to
> vfs_poll() done by io_arm_poll_handler().
>
> Detecting the situation and reissuing the operation is much faster
> than going ahead and push the operation to the io-wq.
The poll stuff is not perfect and definitely can be improved,
but there are drawbacks, with this one fairness may suffer
with higher submit batching and make lat worse for all
but one request.
I'll get to it and another poll related email later,
probably next week.
>
> Signed-off-by: Olivier Langlois <[email protected]>
> ---
> fs/io_uring.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 42380ed563c4..98cf3e323d5e 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -5138,15 +5138,16 @@ static __poll_t __io_arm_poll_handler(struct io_kiocb *req,
> return mask;
> }
>
> -static bool io_arm_poll_handler(struct io_kiocb *req)
> +static bool io_arm_poll_handler(struct io_kiocb *req, __poll_t *ret)
> {
> const struct io_op_def *def = &io_op_defs[req->opcode];
> struct io_ring_ctx *ctx = req->ctx;
> struct async_poll *apoll;
> struct io_poll_table ipt;
> - __poll_t mask, ret;
> + __poll_t mask;
> int rw;
>
> + *ret = 0;
> if (!req->file || !file_can_poll(req->file))
> return false;
> if (req->flags & REQ_F_POLLED)
> @@ -5184,9 +5185,9 @@ static bool io_arm_poll_handler(struct io_kiocb *req)
>
> ipt.pt._qproc = io_async_queue_proc;
>
> - ret = __io_arm_poll_handler(req, &apoll->poll, &ipt, mask,
> + *ret = __io_arm_poll_handler(req, &apoll->poll, &ipt, mask,
> io_async_wake);
> - if (ret || ipt.error) {
> + if (*ret || ipt.error) {
> io_poll_remove_double(req);
> spin_unlock_irq(&ctx->completion_lock);
> return false;
> @@ -6410,7 +6411,9 @@ static void __io_queue_sqe(struct io_kiocb *req)
> {
> struct io_kiocb *linked_timeout = io_prep_linked_timeout(req);
> int ret;
> + __poll_t poll_ret;
>
> +issue_sqe:
> ret = io_issue_sqe(req, IO_URING_F_NONBLOCK|IO_URING_F_COMPLETE_DEFER);
>
> /*
> @@ -6430,7 +6433,9 @@ static void __io_queue_sqe(struct io_kiocb *req)
> io_put_req(req);
> }
> } else if (ret == -EAGAIN && !(req->flags & REQ_F_NOWAIT)) {
> - if (!io_arm_poll_handler(req)) {
> + if (!io_arm_poll_handler(req, &poll_ret)) {
> + if (poll_ret)
> + goto issue_sqe;
> /*
> * Queued up for async execution, worker will release
> * submit reference when the iocb is actually submitted.
>
--
Pavel Begunkov
next parent reply other threads:[~2021-06-10 9:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <[email protected]>
2021-06-10 9:03 ` Pavel Begunkov [this message]
[not found] ` <[email protected]>
2021-06-10 15:51 ` [PATCH] io_uring: reduce latency by reissueing the operation Pavel Begunkov
2021-06-10 17:56 ` Olivier Langlois
2021-06-10 19:32 ` Pavel Begunkov
2021-06-11 3:55 ` Olivier Langlois
2021-06-17 18:10 ` Pavel Begunkov
2021-06-18 22:45 ` Olivier Langlois
2021-06-20 20:55 ` Pavel Begunkov
2021-06-20 21:31 ` Olivier Langlois
2021-06-20 22:04 ` Pavel Begunkov
[not found] <[email protected]>
2021-06-16 12:48 ` Jens Axboe
2021-06-18 21:38 ` Olivier Langlois
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 \
[email protected] \
[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