From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>,
io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] io_uring: fix ctx refcounting in io_submit_sqes()
Date: Mon, 6 Apr 2020 00:13:55 +0300 [thread overview]
Message-ID: <331eb009-a8c3-98c7-4cec-d91a821f22be@gmail.com> (raw)
In-Reply-To: <8b53ce4539784423b493fdbfae9bd4c720b24d2a.1586120916.git.asml.silence@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1163 bytes --]
On 06/04/2020 00:08, Pavel Begunkov wrote:
> If io_get_req() fails, it drops a ref. Then, awhile keeping @submitted
> unmodified, io_submit_sqes() breaks the loop and puts @nr - @submitted
> refs. For each submitted req a ref is dropped in io_put_req() and
> friends. So, for @nr taken refs there will be
> (@nr - @submitted + @submitted + 1) dropped.
>
> Remove ctx refcounting from io_get_req(), that at the same time makes
> it clearer.
It seems, nobody hit OOM, so it stayed unnoticed. And neither did I.
It could be a good idea to do fault-injection for testing.
>
> Fixes: 2b85edfc0c90 ("io_uring: batch getting pcpu references")
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
> fs/io_uring.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 78ae8e8ed5bf..79bd22289d73 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -1342,7 +1342,6 @@ static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx,
> req = io_get_fallback_req(ctx);
> if (req)
> goto got_it;
> - percpu_ref_put(&ctx->refs);
> return NULL;
> }
>
>
--
Pavel Begunkov
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-04-05 21:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-05 21:08 [PATCH] io_uring: fix ctx refcounting in io_submit_sqes() Pavel Begunkov
2020-04-05 21:13 ` Pavel Begunkov [this message]
2020-04-05 22:25 ` Jens Axboe
2020-04-05 22:24 ` 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=331eb009-a8c3-98c7-4cec-d91a821f22be@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@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