提交 a4739140 编写于 作者: P Pavel Begunkov 提交者: Cheng Jian

io_uring: iterate req cache backwards

mainline inclusion
from mainline-5.6-rc1
commit 6c8a3134
category: feature
bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=27
CVE: NA
---------------------------

Grab requests from cache-array from the end, so can get by only
free_reqs.
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: Nyangerkun <yangerkun@huawei.com>
Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 5522214d
......@@ -586,8 +586,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
......@@ -1185,12 +1184,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:
......@@ -4790,8 +4787,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);
}
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册