public inbox for [email protected]
 help / color / mirror / Atom feed
From: Hao Xu <[email protected]>
To: Pavel Begunkov <[email protected]>, [email protected]
Cc: Jens Axboe <[email protected]>
Subject: Re: [PATCH v2 3/4] io_uring: don't spinlock when not posting CQEs
Date: Thu, 25 Nov 2021 11:48:14 +0800	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <8d4b4a08bca022cbe19af00266407116775b3e4d.1636559119.git.asml.silence@gmail.com>

在 2021/11/10 下午11:49, Pavel Begunkov 写道:
> When no of queued for the batch completion requests need to post an CQE,
> see IOSQE_CQE_SKIP_SUCCESS, avoid grabbing ->completion_lock and other
> commit/post.
> 
> Signed-off-by: Pavel Begunkov <[email protected]>
> ---
>   fs/io_uring.c | 26 +++++++++++++++++---------
>   1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 22572cfd6864..0c0ea3bbb50a 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -321,6 +321,7 @@ struct io_submit_state {
>   
>   	bool			plug_started;
>   	bool			need_plug;
> +	bool			flush_cqes;
>   	unsigned short		submit_nr;
>   	struct blk_plug		plug;
>   };
> @@ -1525,8 +1526,11 @@ static void io_prep_async_link(struct io_kiocb *req)
>   
>   static inline void io_req_add_compl_list(struct io_kiocb *req)
>   {
> +	struct io_ring_ctx *ctx = req->ctx;
>   	struct io_submit_state *state = &req->ctx->submit_state;
>   
> +	if (!(req->flags & REQ_F_CQE_SKIP))
> +		ctx->submit_state.flush_cqes = true;
Should we init it to false in submit_state_start()?
>   	wq_list_add_tail(&req->comp_list, &state->compl_reqs);
>   }
>   
> @@ -2386,18 +2390,22 @@ 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;
>   
> -	spin_lock(&ctx->completion_lock);
> -	wq_list_for_each(node, prev, &state->compl_reqs) {
> -		struct io_kiocb *req = container_of(node, struct io_kiocb,
> +	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(ctx, req->user_data, req->result,
> -				      req->cflags);
> +			if (!(req->flags & REQ_F_CQE_SKIP))
> +				__io_fill_cqe(ctx, req->user_data, req->result,
> +					      req->cflags);
> +		}
> +
> +		io_commit_cqring(ctx);
> +		spin_unlock(&ctx->completion_lock);
> +		io_cqring_ev_posted(ctx);
> +		state->flush_cqes = false;
>   	}
> -	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);
> 


  reply	other threads:[~2021-11-25  3:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10 15:49 [PATCH v2 0/4] allow to skip CQE posting Pavel Begunkov
2021-11-10 15:49 ` [PATCH v2 1/4] io_uring: clean cqe filling functions Pavel Begunkov
2021-11-10 15:49 ` [PATCH v2 2/4] io_uring: add option to skip CQE posting Pavel Begunkov
2021-11-10 15:49 ` [PATCH v2 3/4] io_uring: don't spinlock when not posting CQEs Pavel Begunkov
2021-11-25  3:48   ` Hao Xu [this message]
2021-11-25  7:35     ` Hao Xu
2021-11-10 15:49 ` [PATCH v2 4/4] io_uring: disable drain with cqe skip Pavel Begunkov
2021-11-10 16:14 ` [PATCH v2 0/4] allow to skip CQE posting Jens Axboe
2021-11-10 16:42   ` Pavel Begunkov
2021-11-10 16:47     ` Jens Axboe
2021-11-24 17:55       ` Pavel Begunkov
2021-11-24 17:57         ` Jens Axboe
2021-11-24 18:02           ` Pavel Begunkov
2021-11-24 18:17             ` Jens Axboe
2021-11-25  9:35     ` Hao Xu
2021-11-25 14:22       ` Pavel Begunkov
2021-11-24 18:18 ` Jens Axboe
2021-12-06 19:49   ` 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 \
    --in-reply-to=19624295-224b-cbbc-7f63-17d4d5a9d1b9@linux.alibaba.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