From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
[email protected], [email protected]
Subject: [PATCH 4/6] io_uring: separate DRAIN flushing into a cold path
Date: Tue, 26 May 2020 20:34:05 +0300 [thread overview]
Message-ID: <2f9403ad657d7f8eaaa2687d68a2d05599812e7e.1590513806.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
io_commit_cqring() assembly doesn't look good with extra code handling
drained requests. IOSQE_IO_DRAIN is slow and discouraged to be used in
a hot path, so try to minimise its impact by putting it into a helper
and doing a fast check.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 067ebdeb1ba4..acf6ce9eee68 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -982,19 +982,6 @@ static inline bool req_need_defer(struct io_kiocb *req)
return false;
}
-static struct io_kiocb *io_get_deferred_req(struct io_ring_ctx *ctx)
-{
- struct io_kiocb *req;
-
- req = list_first_entry_or_null(&ctx->defer_list, struct io_kiocb, list);
- if (req && !req_need_defer(req)) {
- list_del_init(&req->list);
- return req;
- }
-
- return NULL;
-}
-
static struct io_kiocb *io_get_timeout_req(struct io_ring_ctx *ctx)
{
struct io_kiocb *req;
@@ -1127,6 +1114,19 @@ static void io_kill_timeouts(struct io_ring_ctx *ctx)
spin_unlock_irq(&ctx->completion_lock);
}
+static void __io_queue_deferred(struct io_ring_ctx *ctx)
+{
+ do {
+ struct io_kiocb *req = list_first_entry(&ctx->defer_list,
+ struct io_kiocb, list);
+
+ if (req_need_defer(req))
+ break;
+ list_del_init(&req->list);
+ io_queue_async_work(req);
+ } while (!list_empty(&ctx->defer_list));
+}
+
static void io_commit_cqring(struct io_ring_ctx *ctx)
{
struct io_kiocb *req;
@@ -1136,8 +1136,8 @@ static void io_commit_cqring(struct io_ring_ctx *ctx)
__io_commit_cqring(ctx);
- while ((req = io_get_deferred_req(ctx)) != NULL)
- io_queue_async_work(req);
+ if (unlikely(!list_empty(&ctx->defer_list)))
+ __io_queue_deferred(ctx);
}
static struct io_uring_cqe *io_get_cqring(struct io_ring_ctx *ctx)
--
2.24.0
next prev parent reply other threads:[~2020-05-26 17:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-26 17:34 [PATCH 0/6] random patches for 5.8 Pavel Begunkov
2020-05-26 17:34 ` [PATCH 1/6] io_uring: fix flush req->refs underflow Pavel Begunkov
2020-05-26 18:04 ` Jens Axboe
2020-05-26 17:34 ` [PATCH 2/6] io_uring: simplify io_timeout locking Pavel Begunkov
2020-05-26 17:34 ` [PATCH 3/6] io_uring: don't re-read sqe->off in timeout_prep() Pavel Begunkov
2020-05-26 17:34 ` Pavel Begunkov [this message]
2020-05-26 17:34 ` [PATCH 5/6] io_uring: get rid of manual punting in io_close Pavel Begunkov
2020-05-26 17:34 ` [PATCH 6/6] io_uring: let io_req_aux_free() handle fixed files Pavel Begunkov
2020-05-26 18:03 ` Jens Axboe
2020-05-26 18:11 ` Pavel Begunkov
2020-05-26 19:32 ` [PATCH 0/6] random patches for 5.8 Jens Axboe
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=2f9403ad657d7f8eaaa2687d68a2d05599812e7e.1590513806.git.asml.silence@gmail.com \
[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