Re: [PATCH 2/2] io_uring/msg_ring: use kmem_cache_free() to free request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jens Axboe <axboe@xxxxxxxxx> writes:

> The change adding caching around the request allocated and freed for
> data messages changed a kmem_cache_free() to a kfree(), which isn't
> correct as the request came from slab in the first place. Fix that up
> and use the right freeing function if the cache is already at its limit.
>
> Fixes: 50cf5f3842af ("io_uring/msg_ring: add an alloc cache for io_kiocb entries")
> Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>

Fwiw, kfree works fine for kmem_cache_alloc objects since 6.4, when SLOB
was removed.  Either way, it doesn't harm.

> ---
>  io_uring/msg_ring.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/io_uring/msg_ring.c b/io_uring/msg_ring.c
> index c2171495098b..29fa9285a33d 100644
> --- a/io_uring/msg_ring.c
> +++ b/io_uring/msg_ring.c
> @@ -82,7 +82,7 @@ static void io_msg_tw_complete(struct io_kiocb *req, struct io_tw_state *ts)
>  		spin_unlock(&ctx->msg_lock);
>  	}
>  	if (req)
> -		kfree(req);
> +		kmem_cache_free(req_cachep, req);
>  	percpu_ref_put(&ctx->refs);
>  }

-- 
Gabriel Krisman Bertazi




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux