diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2020-02-01 03:58:00 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-02-04 03:27:47 +0300 |
commit | 6c8a31346925cbb373f84a18428ab3df59d3950e (patch) | |
tree | 87bb9e9e3d667dbaec2b74a4d4d1365b7e8cb168 /fs/io_uring.c | |
parent | 3e69426da2599677ebbe76e2d97a606c4797bd74 (diff) | |
download | linux-6c8a31346925cbb373f84a18428ab3df59d3950e.tar.xz |
io_uring: iterate req cache backwards
Grab requests from cache-array from the end, so can get by only
free_reqs.
Signed-off-by: Pavel Begunkov <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 | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 1580f1e7ba1c..42b45c57c3f8 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -585,8 +585,7 @@ struct io_submit_state { * io_kiocb alloc cache */ void *reqs[IO_IOPOLL_BATCH]; - unsigned int free_reqs; - unsigned int cur_req; + unsigned int free_reqs; /* * File reference cache @@ -1190,12 +1189,10 @@ static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx, ret = 1; } state->free_reqs = ret - 1; - state->cur_req = 1; - req = state->reqs[0]; + req = state->reqs[ret - 1]; } else { - req = state->reqs[state->cur_req]; state->free_reqs--; - state->cur_req++; + req = state->reqs[state->free_reqs]; } got_it: @@ -4849,8 +4846,7 @@ static void io_submit_state_end(struct io_submit_state *state) blk_finish_plug(&state->plug); io_file_put(state); if (state->free_reqs) - kmem_cache_free_bulk(req_cachep, state->free_reqs, - &state->reqs[state->cur_req]); + kmem_cache_free_bulk(req_cachep, state->free_reqs, state->reqs); } /* |