public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: Dylan Yudaken <[email protected]>, Pavel Begunkov <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [PATCH for-next 09/10] io_uring: allow io_post_aux_cqe to defer completion
Date: Mon, 21 Nov 2022 09:55:54 -0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 11/21/22 3:03 AM, Dylan Yudaken wrote:
> Use the just introduced deferred post cqe completion state when possible
> in io_post_aux_cqe.
> 
> Signed-off-by: Dylan Yudaken <[email protected]>
> ---
>  io_uring/io_uring.c | 21 ++++++++++++++++++++-
>  io_uring/io_uring.h |  2 +-
>  io_uring/msg_ring.c | 10 ++++++----
>  io_uring/net.c      | 15 ++++++++-------
>  io_uring/poll.c     |  2 +-
>  io_uring/rsrc.c     |  4 ++--
>  6 files changed, 38 insertions(+), 16 deletions(-)
> 
> diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
> index c797f9a75dfe..5c240d01278a 100644
> --- a/io_uring/io_uring.c
> +++ b/io_uring/io_uring.c
> @@ -845,11 +845,30 @@ static void __io_flush_post_cqes(struct io_ring_ctx *ctx)
>  	state->cqes_count = 0;
>  }
>  
> -bool io_post_aux_cqe(struct io_ring_ctx *ctx,
> +bool io_post_aux_cqe(struct io_ring_ctx *ctx, bool defer,
>  		     u64 user_data, s32 res, u32 cflags)
>  {
>  	bool filled;
>  
> +	if (defer) {
> +		unsigned int length = ARRAY_SIZE(ctx->submit_state.cqes);
> +		struct io_uring_cqe *cqe;
> +
> +		lockdep_assert_held(&ctx->uring_lock);
> +
> +		if (ctx->submit_state.cqes_count == length) {
> +			io_cq_lock(ctx);
> +			__io_flush_post_cqes(ctx);
> +			/* no need to flush - flush is deferred */
> +			spin_unlock(&ctx->completion_lock);
> +		}
> +
> +		cqe  = ctx->submit_state.cqes + ctx->submit_state.cqes_count++;
> +		cqe->user_data = user_data;
> +		cqe->res = res;
> +		cqe->flags = cflags;
> +		return true;
> +	}
>  	io_cq_lock(ctx);
>  	filled = io_fill_cqe_aux(ctx, user_data, res, cflags);
>  	io_cq_unlock_post(ctx);

Seems like this would be cleaner with a separate helper and make that
decision in the caller. For the ones that just pass false that is
trivial of course, then just gate it on the locked nature of the ring in
the other spots?

-- 
Jens Axboe

  reply	other threads:[~2022-11-21 16:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 10:03 [PATCH for-next 00/10] io_uring: batch multishot completions Dylan Yudaken
2022-11-21 10:03 ` [PATCH for-next 01/10] io_uring: merge io_req_tw_post and io_req_task_complete Dylan Yudaken
2022-11-21 10:03 ` [PATCH for-next 02/10] io_uring: __io_req_complete should defer if available Dylan Yudaken
2022-11-21 10:03 ` [PATCH for-next 03/10] io_uring: split io_req_complete_failed into post/defer Dylan Yudaken
2022-11-21 10:03 ` [PATCH for-next 04/10] io_uring: lock on remove in io_apoll_task_func Dylan Yudaken
2022-11-21 10:03 ` [PATCH for-next 05/10] io_uring: timeout should use io_req_task_complete Dylan Yudaken
2022-11-21 10:03 ` [PATCH for-next 06/10] io_uring: simplify io_issue_sqe Dylan Yudaken
2022-11-21 10:03 ` [PATCH for-next 07/10] io_uring: make io_req_complete_post static Dylan Yudaken
2022-11-21 10:03 ` [PATCH for-next 08/10] io_uring: allow defer completion for aux posted cqes Dylan Yudaken
2022-11-21 10:03 ` [PATCH for-next 09/10] io_uring: allow io_post_aux_cqe to defer completion Dylan Yudaken
2022-11-21 16:55   ` Jens Axboe [this message]
2022-11-21 17:31   ` Jens Axboe
2022-11-21 10:03 ` [PATCH for-next 10/10] io_uring: allow multishot polled reqs " Dylan Yudaken

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