linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>,
	io-uring@vger.kernel.org, linux-block@vger.kernel.org
Subject: Re: [PATCH v3 1/3] io_uring: allocate io_kiocb upfront
Date: Thu, 7 Nov 2019 01:47:18 +0300	[thread overview]
Message-ID: <09d804b1-1bb8-1ecc-91f7-6aa7a766c90e@gmail.com> (raw)
In-Reply-To: <b787787e16af14f03df2ee1ac0d57b81b367cb4c.1573079844.git.asml.silence@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2828 bytes --]

On 07/11/2019 01:41, Pavel Begunkov wrote:
> Let io_submit_sqes() to allocate io_kiocb before fetching an sqe.
> 
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
>  fs/io_uring.c | 27 ++++++++++++++-------------
>  1 file changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 6524898831e0..ceb616dbe710 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -2551,30 +2551,23 @@ static int io_queue_link_head(struct io_ring_ctx *ctx, struct io_kiocb *req,
>  
>  #define SQE_VALID_FLAGS	(IOSQE_FIXED_FILE|IOSQE_IO_DRAIN|IOSQE_IO_LINK)
>  
> -static void io_submit_sqe(struct io_ring_ctx *ctx, struct sqe_submit *s,
> -			  struct io_submit_state *state, struct io_kiocb **link)
> +static void io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,
> +			  struct sqe_submit *s, struct io_submit_state *state,
> +			  struct io_kiocb **link)
>  {
>  	struct io_uring_sqe *sqe_copy;
> -	struct io_kiocb *req;
>  	int ret;
>  
>  	/* enforce forwards compatibility on users */
>  	if (unlikely(s->sqe->flags & ~SQE_VALID_FLAGS)) {
>  		ret = -EINVAL;
> -		goto err;
> -	}
> -
> -	req = io_get_req(ctx, state);
> -	if (unlikely(!req)) {
> -		ret = -EAGAIN;
> -		goto err;
> +		goto err_req;
>  	}
>  
>  	ret = io_req_set_file(ctx, s, state, req);
>  	if (unlikely(ret)) {
>  err_req:
>  		io_free_req(req, NULL);
> -err:
>  		io_cqring_add_event(ctx, s->sqe->user_data, ret);
>  		return;
>  	}
> @@ -2710,9 +2703,15 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
>  
>  	for (i = 0; i < nr; i++) {
>  		struct sqe_submit s;
> +		struct io_kiocb *req;
>  
> -		if (!io_get_sqring(ctx, &s))
> +		req = io_get_req(ctx, statep);
> +		if (unlikely(!req))
>  			break;
> +		if (!io_get_sqring(ctx, &s)) {
> +			__io_free_req(req);
> +			break;
> +		}
>  
>  		if (io_sqe_needs_user(s.sqe) && !*mm) {
>  			mm_fault = mm_fault || !mmget_not_zero(ctx->sqo_mm);
> @@ -2740,7 +2739,7 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
>  		s.in_async = async;
>  		s.needs_fixed_file = async;
>  		trace_io_uring_submit_sqe(ctx, s.sqe->user_data, true, async);
> -		io_submit_sqe(ctx, &s, statep, &link);
> +		io_submit_sqe(ctx, req, &s, statep, &link);
>  		submitted++;
>  
>  		/*
> @@ -4009,6 +4008,8 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
>  		cur_mm = ctx->sqo_mm;
>  		submitted = io_submit_sqes(ctx, to_submit, f.file, fd,
>  					   &cur_mm, false);
> +		if (!submitted)
> +			submitted = -EAGAIN;

Need to say, that left io_submit_sqes() errors of more priority than ones of
poll/wait.


>  		mutex_unlock(&ctx->uring_lock);
>  	}
>  	if (flags & IORING_ENTER_GETEVENTS) {
> 

-- 
Pavel Begunkov


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-11-06 22:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06 22:41 [PATCH v3 0/3] Inline sqe_submit Pavel Begunkov
2019-11-06 22:41 ` [PATCH v3 1/3] io_uring: allocate io_kiocb upfront Pavel Begunkov
2019-11-06 22:47   ` Pavel Begunkov [this message]
2019-11-06 22:41 ` [PATCH v3 2/3] io_uring: Use submit info inlined into req Pavel Begunkov
2019-11-06 22:41 ` [PATCH v3 3/3] io_uring: use inlined struct sqe_submit Pavel Begunkov
2019-11-06 22:47 ` [PATCH v3 0/3] Inline sqe_submit 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=09d804b1-1bb8-1ecc-91f7-6aa7a766c90e@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).