io_uring/rw: simplify io_rw_recycle()

JIRA: https://issues.redhat.com/browse/RHEL-105612

commit d1fdab8c06791945d9454fb430951533eba9e175
Author: Pavel Begunkov <asml.silence@gmail.com>
Date:   Tue Jan 28 20:56:16 2025 +0000

    io_uring/rw: simplify io_rw_recycle()
    
    Instead of freeing iovecs in case of IO_URING_F_UNLOCKED in
    io_rw_recycle(), leave it be and rely on the core io_uring code to
    call io_readv_writev_cleanup() later. This way the iovec will get
    recycled and we can clean up io_rw_recycle() and kill
    io_rw_iovec_free().
    
    Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
    Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
    Link: https://lore.kernel.org/r/14f83b112eb40078bea18e15d77a4f99fc981a44.1738087204.git.asml.silence@gmail.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
This commit is contained in:
Jeff Moyer
2025-10-27 13:08:31 -04:00
parent 3867962b08
commit 8832ab68c0
+3 -13
View File
@@ -146,23 +146,13 @@ static inline int io_import_iovec(int rw, struct io_kiocb *req,
return 0;
}
static void io_rw_iovec_free(struct io_async_rw *rw)
{
if (rw->free_iovec) {
kfree(rw->free_iovec);
rw->free_iov_nr = 0;
rw->free_iovec = NULL;
}
}
static void io_rw_recycle(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_async_rw *rw = req->async_data;
if (unlikely(issue_flags & IO_URING_F_UNLOCKED)) {
io_rw_iovec_free(rw);
if (unlikely(issue_flags & IO_URING_F_UNLOCKED))
return;
}
io_alloc_cache_kasan(&rw->free_iovec, &rw->free_iov_nr);
if (io_alloc_cache_put(&req->ctx->rw_cache, rw)) {
req->async_data = NULL;
@@ -1311,6 +1301,6 @@ void io_rw_cache_free(const void *entry)
struct io_async_rw *rw = (struct io_async_rw *) entry;
if (rw->free_iovec)
io_rw_iovec_free(rw);
kfree(rw->free_iovec);
kfree(rw);
}