* [PATCH] io_uring/rsrc: use io_cache_free() to free node allocated by io_rsrc_node_alloc()
@ 2026-03-31 10:45 Jackie Liu
2026-03-31 13:35 ` Jens Axboe
2026-03-31 13:36 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Jackie Liu @ 2026-03-31 10:45 UTC (permalink / raw)
To: axboe; +Cc: io-uring
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;
}
--
2.51.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring/rsrc: use io_cache_free() to free node allocated by io_rsrc_node_alloc()
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
2026-03-31 13:36 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2026-03-31 13:35 UTC (permalink / raw)
To: Jackie Liu; +Cc: io-uring
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] io_uring/rsrc: use io_cache_free() to free node allocated by io_rsrc_node_alloc()
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
@ 2026-03-31 13:36 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2026-03-31 13:36 UTC (permalink / raw)
To: Jackie Liu; +Cc: io-uring
On Tue, 31 Mar 2026 18:45:09 +0800, Jackie Liu wrote:
> 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.
>
>
> [...]
Applied, thanks!
[1/1] io_uring/rsrc: use io_cache_free() to free node allocated by io_rsrc_node_alloc()
commit: 37912f1ea4ee2d8a4f36033fea4f44a044dd1cb9
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-31 13:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-03-31 13:36 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox