Skip to content

Commit d1fdab8

Browse files
isilenceaxboe
authored andcommitted
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>
1 parent 0d12457 commit d1fdab8

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

io_uring/rw.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,13 @@ static inline int io_import_iovec(int rw, struct io_kiocb *req,
146146
return 0;
147147
}
148148

149-
static void io_rw_iovec_free(struct io_async_rw *rw)
150-
{
151-
if (rw->free_iovec) {
152-
kfree(rw->free_iovec);
153-
rw->free_iov_nr = 0;
154-
rw->free_iovec = NULL;
155-
}
156-
}
157-
158149
static void io_rw_recycle(struct io_kiocb *req, unsigned int issue_flags)
159150
{
160151
struct io_async_rw *rw = req->async_data;
161152

162-
if (unlikely(issue_flags & IO_URING_F_UNLOCKED)) {
163-
io_rw_iovec_free(rw);
153+
if (unlikely(issue_flags & IO_URING_F_UNLOCKED))
164154
return;
165-
}
155+
166156
io_alloc_cache_kasan(&rw->free_iovec, &rw->free_iov_nr);
167157
if (io_alloc_cache_put(&req->ctx->rw_cache, rw)) {
168158
req->async_data = NULL;
@@ -1310,6 +1300,6 @@ void io_rw_cache_free(const void *entry)
13101300
struct io_async_rw *rw = (struct io_async_rw *) entry;
13111301

13121302
if (rw->free_iovec)
1313-
io_rw_iovec_free(rw);
1303+
kfree(rw->free_iovec);
13141304
kfree(rw);
13151305
}

0 commit comments

Comments
 (0)