From: Jens Axboe <axboe@kernel.dk>
To: Jackie Liu <liu.yun@linux.dev>
Cc: io-uring@vger.kernel.org
Subject: Re: [PATCH] io_uring/rsrc: use io_cache_free() to free node allocated by io_rsrc_node_alloc()
Date: Tue, 31 Mar 2026 07:35:56 -0600 [thread overview]
Message-ID: <b826c51c-4d5a-4e87-85d2-69b551a7e5a7@kernel.dk> (raw)
In-Reply-To: <20260331104509.7055-1-liu.yun@linux.dev>
On 3/31/26 4:45 AM, Jackie Liu wrote:
> From: Jackie Liu <liuyun01@kylinos.cn>
>
> Replace kfree(node) with io_cache_free() in io_buffer_register_bvec()
> to match all other error paths that free nodes allocated via
> io_rsrc_node_alloc(). The node is allocated through io_cache_alloc()
> internally, so it should be returned to the cache via io_cache_free()
> for proper object reuse.
>
> Fixes: 27cb27b6d5ea ("io_uring: add support for kernel registered bvecs")
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
> io_uring/rsrc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> index 4fa59bf89bba..c4a7b29a327c 100644
> --- a/io_uring/rsrc.c
> +++ b/io_uring/rsrc.c
> @@ -961,7 +961,7 @@ int io_buffer_register_bvec(struct io_uring_cmd *cmd, struct request *rq,
> */
> imu = io_alloc_imu(ctx, blk_rq_nr_phys_segments(rq));
> if (!imu) {
> - kfree(node);
> + io_cache_free(&ctx->node_cache, node);
> ret = -ENOMEM;
> goto unlock;
> }
People have sent this before, but I usually just dismiss it with being
an error path and it doesn't matter one bit if it stays in cache or just
gets freed outright. But might make sense to apply it just for
consistency's sake - and so I don't get it sent again!
--
Jens Axboe
next prev parent reply other threads:[~2026-03-31 13:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 10:45 [PATCH] io_uring/rsrc: use io_cache_free() to free node allocated by io_rsrc_node_alloc() Jackie Liu
2026-03-31 13:35 ` Jens Axboe [this message]
2026-03-31 13:36 ` 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=b826c51c-4d5a-4e87-85d2-69b551a7e5a7@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=liu.yun@linux.dev \
/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