Commit 6c8a3134 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: iterate req cache backwards

Grab requests from cache-array from the end, so can get by only
free_reqs.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 3e69426d
...@@ -586,7 +586,6 @@ struct io_submit_state { ...@@ -586,7 +586,6 @@ struct io_submit_state {
*/ */
void *reqs[IO_IOPOLL_BATCH]; void *reqs[IO_IOPOLL_BATCH];
unsigned int free_reqs; unsigned int free_reqs;
unsigned int cur_req;
/* /*
* File reference cache * File reference cache
...@@ -1190,12 +1189,10 @@ static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx, ...@@ -1190,12 +1189,10 @@ static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx,
ret = 1; ret = 1;
} }
state->free_reqs = ret - 1; state->free_reqs = ret - 1;
state->cur_req = 1; req = state->reqs[ret - 1];
req = state->reqs[0];
} else { } else {
req = state->reqs[state->cur_req];
state->free_reqs--; state->free_reqs--;
state->cur_req++; req = state->reqs[state->free_reqs];
} }
got_it: got_it:
...@@ -4849,8 +4846,7 @@ static void io_submit_state_end(struct io_submit_state *state) ...@@ -4849,8 +4846,7 @@ static void io_submit_state_end(struct io_submit_state *state)
blk_finish_plug(&state->plug); blk_finish_plug(&state->plug);
io_file_put(state); io_file_put(state);
if (state->free_reqs) if (state->free_reqs)
kmem_cache_free_bulk(req_cachep, state->free_reqs, kmem_cache_free_bulk(req_cachep, state->free_reqs, state->reqs);
&state->reqs[state->cur_req]);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment