Skip to content

Commit

Permalink
io_uring: reuse io_alloc_req()
Browse files Browse the repository at this point in the history
Don't duplicate io_alloc_req() in io_req_caches_free() but reuse the
helper.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/6005fc88274864a49fc3096c22d8bdd605cf8576.1665891182.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Pavel Begunkov authored and Jens Axboe committed Oct 16, 2022
1 parent 4d50595 commit 34f0bc4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions io_uring/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -2560,18 +2560,14 @@ static int io_eventfd_unregister(struct io_ring_ctx *ctx)

static void io_req_caches_free(struct io_ring_ctx *ctx)
{
struct io_submit_state *state = &ctx->submit_state;
int nr = 0;

mutex_lock(&ctx->uring_lock);
io_flush_cached_locked_reqs(ctx, state);
io_flush_cached_locked_reqs(ctx, &ctx->submit_state);

while (!io_req_cache_empty(ctx)) {
struct io_wq_work_node *node;
struct io_kiocb *req;
struct io_kiocb *req = io_alloc_req(ctx);

node = wq_stack_extract(&state->free_list);
req = container_of(node, struct io_kiocb, comp_list);
kmem_cache_free(req_cachep, req);
nr++;
}
Expand Down

0 comments on commit 34f0bc4

Please sign in to comment.