io-uring.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
Subject: Re: fixup for "io_uring: allocate io_kiocb upfront"
Date: Thu, 7 Nov 2019 12:24:05 +0300	[thread overview]
Message-ID: <2ed217ce-6a17-7364-6752-73b16ff6fc2f@gmail.com> (raw)
In-Reply-To: <4e41bfad-d7ec-6381-741c-0261f321617a@kernel.dk>


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

On 07/11/2019 06:20, Jens Axboe wrote:
> Pavel,
> 
> I didn't read this one closely enough for the latest change, we
> can't just return -EAGAIN if we don't submit anything, we have to
> explicitly do it for just the failure case of not getting a request.
> I'm going to fold in this incremental:
> 
My bad, it should be a common case to have @to_submit >= nr_sqes_in_ring
(i.e. I don't care, just submit all). Thanks for fixing it.
Also, if it submitted @n (>0), and can't allocate for @n+1, I'd rather
prefer to get submitted count.

BTW, I found this "one return value for both submit() and wait_cqes()"
a bit confusing. In addition, there is reporting through cqe, and
sometimes they could be interchanged like in this case. It's getting
even more trickier with links.
Maybe, you have some write-up on what to expect from this perspective?
Don't remember it to be in the pdf.


> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 951fd09612ec..af8a673c618f 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -2978,8 +2978,11 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
>  		unsigned int sqe_flags;
>  
>  		req = io_get_req(ctx, statep);
> -		if (unlikely(!req))
> +		if (unlikely(!req)) {
> +			if (!submitted)
> +				submitted = -EAGAIN;
>  			break;
> +		}
>  		if (!io_get_sqring(ctx, &req->submit)) {
>  			__io_free_req(req);
>  			break;
> @@ -4316,8 +4319,6 @@ 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;
>  		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-07  9:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-07  3:20 fixup for "io_uring: allocate io_kiocb upfront" Jens Axboe
2019-11-07  9:24 ` Pavel Begunkov [this message]

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=2ed217ce-6a17-7364-6752-73b16ff6fc2f@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@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).