diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-08-09 20:18:08 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-08-23 13:09:43 -0600 |
commit | c34b025f2d2149d4351b994a923fa687a32478f8 (patch) | |
tree | dd1c14cc5d6e8cea6a1888ce773dfcf074581a54 /fs/io_uring.c | |
parent | f56165e62fae78200292857628e4f1d8d12a0ed0 (diff) | |
download | linux-stable-c34b025f2d2149d4351b994a923fa687a32478f8.tar.gz linux-stable-c34b025f2d2149d4351b994a923fa687a32478f8.tar.bz2 linux-stable-c34b025f2d2149d4351b994a923fa687a32478f8.zip |
io_uring: cache __io_free_req()'d requests
Don't kfree requests in __io_free_req() but put them back into the
internal request cache. That makes allocations more sustainable and will
be used for refcounting optimisations.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/9f4950fbe7771c8d41799366d0a3a08ac3040236.1628536684.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 86162ebd6bae..cc2d3de16423 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1831,11 +1831,16 @@ static void io_dismantle_req(struct io_kiocb *req) static void __io_free_req(struct io_kiocb *req) { struct io_ring_ctx *ctx = req->ctx; + unsigned long flags; io_dismantle_req(req); io_put_task(req->task, 1); - kmem_cache_free(req_cachep, req); + spin_lock_irqsave(&ctx->completion_lock, flags); + list_add(&req->compl.list, &ctx->locked_free_list); + ctx->locked_free_nr++; + spin_unlock_irqrestore(&ctx->completion_lock, flags); + percpu_ref_put(&ctx->refs); } |