public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH for-next 5/7] io_uring: remove ->flush_cqes optimisation
Date: Sun, 19 Jun 2022 12:26:08 +0100	[thread overview]
Message-ID: <692e81eeddccc096f449a7960365fa7b4a18f8e6.1655637157.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

It's not clear how widely used IOSQE_CQE_SKIP_SUCCESS is, and how often
->flush_cqes flag prevents from completion being flushed. Sometimes it's
high level of concurrency that enables it at least for one CQE, but
sometimes it doesn't save much because nobody waiting on the CQ.

Remove ->flush_cqes flag and the optimisation, it should benefit the
normal use case. Note, that there is no spurious eventfd problem with
that as checks for spuriousness were incorporated into
io_eventfd_signal().

Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/io_uring.c | 23 ++++++++++-------------
 io_uring/io_uring.h |  2 --
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 0875cc649e23..57aef092ef38 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1253,22 +1253,19 @@ static void __io_submit_flush_completions(struct io_ring_ctx *ctx)
 	struct io_wq_work_node *node, *prev;
 	struct io_submit_state *state = &ctx->submit_state;
 
-	if (state->flush_cqes) {
-		spin_lock(&ctx->completion_lock);
-		wq_list_for_each(node, prev, &state->compl_reqs) {
-			struct io_kiocb *req = container_of(node, struct io_kiocb,
-						    comp_list);
-
-			if (!(req->flags & REQ_F_CQE_SKIP))
-				__io_fill_cqe_req(ctx, req);
-		}
+	spin_lock(&ctx->completion_lock);
+	wq_list_for_each(node, prev, &state->compl_reqs) {
+		struct io_kiocb *req = container_of(node, struct io_kiocb,
+					    comp_list);
 
-		io_commit_cqring(ctx);
-		spin_unlock(&ctx->completion_lock);
-		io_cqring_ev_posted(ctx);
-		state->flush_cqes = false;
+		if (!(req->flags & REQ_F_CQE_SKIP))
+			__io_fill_cqe_req(ctx, req);
 	}
 
+	io_commit_cqring(ctx);
+	spin_unlock(&ctx->completion_lock);
+	io_cqring_ev_posted(ctx);
+
 	io_free_batch_list(ctx, state->compl_reqs.first);
 	INIT_WQ_LIST(&state->compl_reqs);
 }
diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h
index 906749fa3415..7feef8c36db7 100644
--- a/io_uring/io_uring.h
+++ b/io_uring/io_uring.h
@@ -232,8 +232,6 @@ static inline void io_req_complete_defer(struct io_kiocb *req)
 
 	lockdep_assert_held(&req->ctx->uring_lock);
 
-	if (!(req->flags & REQ_F_CQE_SKIP))
-		state->flush_cqes = true;
 	wq_list_add_tail(&req->comp_list, &state->compl_reqs);
 }
 
-- 
2.36.1


  parent reply	other threads:[~2022-06-19 11:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-19 11:26 [PATCH for-next 0/7] cqe posting cleanups Pavel Begunkov
2022-06-19 11:26 ` [PATCH for-next 1/7] io_uring: remove extra io_commit_cqring() Pavel Begunkov
2022-06-19 11:26 ` [PATCH for-next 2/7] io_uring: reshuffle io_uring/io_uring.h Pavel Begunkov
2022-06-19 11:26 ` [PATCH for-next 3/7] io_uring: move io_eventfd_signal() Pavel Begunkov
2022-06-19 11:26 ` [PATCH for-next 4/7] io_uring: hide eventfd assumptions in evenfd paths Pavel Begunkov
2022-06-19 18:18   ` Jens Axboe
2022-06-19 18:49     ` Pavel Begunkov
2022-06-19 18:58       ` Jens Axboe
2022-06-19 11:26 ` Pavel Begunkov [this message]
2022-06-19 13:31   ` [PATCH for-next 5/7] io_uring: remove ->flush_cqes optimisation Jens Axboe
2022-06-19 14:52     ` Pavel Begunkov
2022-06-19 15:52       ` Jens Axboe
2022-06-19 16:15         ` Pavel Begunkov
2022-06-19 16:17           ` Jens Axboe
2022-06-19 16:19             ` Pavel Begunkov
2022-06-19 16:38               ` Jens Axboe
2022-06-19 16:38               ` Jens Axboe
2022-06-19 11:26 ` [PATCH for-next 6/7] io_uring: introduce locking helpers for CQE posting Pavel Begunkov
2022-06-19 13:30   ` Jens Axboe
2022-06-19 14:20     ` Pavel Begunkov
2022-06-19 15:50       ` Jens Axboe
2022-06-19 11:26 ` [PATCH for-next 7/7] io_uring: add io_commit_cqring_flush() Pavel Begunkov
2022-06-19 12:36 ` [PATCH for-next 0/7] cqe posting cleanups Pavel Begunkov
2022-06-19 16:01 ` 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=692e81eeddccc096f449a7960365fa7b4a18f8e6.1655637157.git.asml.silence@gmail.com \
    [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