Commit 4b628aeb authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: kill off ios_left

->ios_left is only used to decide whether to plug or not, kill it to
avoid this extra accounting, just use the initial submission number.
There is no much difference in regards of enabling plugging, where this
one does it in a few more cases, but all major ones should be covered
well.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/f13993bcf5b477f9a7d52881fc49f9457ea9870a.1631115443.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 71e1cef2
...@@ -315,6 +315,7 @@ struct io_submit_state { ...@@ -315,6 +315,7 @@ struct io_submit_state {
unsigned int free_reqs; unsigned int free_reqs;
bool plug_started; bool plug_started;
bool need_plug;
/* /*
* Batch completion logic * Batch completion logic
...@@ -323,8 +324,6 @@ struct io_submit_state { ...@@ -323,8 +324,6 @@ struct io_submit_state {
unsigned int compl_nr; unsigned int compl_nr;
/* inline/task_work completion list, under ->uring_lock */ /* inline/task_work completion list, under ->uring_lock */
struct list_head free_list; struct list_head free_list;
unsigned int ios_left;
}; };
struct io_ring_ctx { struct io_ring_ctx {
...@@ -7090,10 +7089,10 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, ...@@ -7090,10 +7089,10 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
* Plug now if we have more than 1 IO left after this, and the target * Plug now if we have more than 1 IO left after this, and the target
* is potentially a read/write to block based storage. * is potentially a read/write to block based storage.
*/ */
if (!state->plug_started && state->ios_left > 1 && if (state->need_plug && io_op_defs[req->opcode].plug) {
io_op_defs[req->opcode].plug) {
blk_start_plug(&state->plug); blk_start_plug(&state->plug);
state->plug_started = true; state->plug_started = true;
state->need_plug = false;
} }
if (io_op_defs[req->opcode].needs_file) { if (io_op_defs[req->opcode].needs_file) {
...@@ -7102,8 +7101,6 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, ...@@ -7102,8 +7101,6 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
if (unlikely(!req->file)) if (unlikely(!req->file))
ret = -EBADF; ret = -EBADF;
} }
state->ios_left--;
return ret; return ret;
} }
...@@ -7212,7 +7209,7 @@ static void io_submit_state_start(struct io_submit_state *state, ...@@ -7212,7 +7209,7 @@ static void io_submit_state_start(struct io_submit_state *state,
unsigned int max_ios) unsigned int max_ios)
{ {
state->plug_started = false; state->plug_started = false;
state->ios_left = max_ios; state->need_plug = max_ios > 2;
/* set only head, no need to init link_last in advance */ /* set only head, no need to init link_last in advance */
state->link.head = NULL; state->link.head = NULL;
} }
......
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