提交 c34b025f 编写于 作者: P Pavel Begunkov 提交者: Jens Axboe

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: NPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/9f4950fbe7771c8d41799366d0a3a08ac3040236.1628536684.git.asml.silence@gmail.comSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 f56165e6
...@@ -1831,11 +1831,16 @@ static void io_dismantle_req(struct io_kiocb *req) ...@@ -1831,11 +1831,16 @@ static void io_dismantle_req(struct io_kiocb *req)
static void __io_free_req(struct io_kiocb *req) static void __io_free_req(struct io_kiocb *req)
{ {
struct io_ring_ctx *ctx = req->ctx; struct io_ring_ctx *ctx = req->ctx;
unsigned long flags;
io_dismantle_req(req); io_dismantle_req(req);
io_put_task(req->task, 1); 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); percpu_ref_put(&ctx->refs);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册