From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: io-uring@vger.kernel.org, asml.silence@gmail.com
Subject: Re: [PATCH 2/2] io_uring/msg_ring: use kmem_cache_free() to free request
Date: Tue, 02 Jul 2024 11:17:43 -0400 [thread overview]
Message-ID: <87ikxnzuug.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <20240701144908.19602-3-axboe@kernel.dk> (Jens Axboe's message of "Mon, 1 Jul 2024 08:48:00 -0600")
Jens Axboe <axboe@kernel.dk> 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@kernel.dk>
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
next prev parent reply other threads:[~2024-07-02 15:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 14:47 [PATCHSET for-next 0/2] msg_ring fixes Jens Axboe
2024-07-01 14:47 ` [PATCH 1/2] io_uring/msg_ring: check for dead submitter task Jens Axboe
2024-07-01 14:48 ` [PATCH 2/2] io_uring/msg_ring: use kmem_cache_free() to free request Jens Axboe
2024-07-02 15:17 ` Gabriel Krisman Bertazi [this message]
2024-07-02 15:18 ` 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=87ikxnzuug.fsf@mailhost.krisman.be \
--to=krisman@suse.de \
--cc=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