__io_queue_sqe() cleanups
cover __io_queue_sqe() cleanups
Refactor __io_queue_sqe(). Easier to read, hopefully better optimisable.
Pavel Begunkov (3):
io_uring: don't miss setting IO_WQ_WORK_CONCURRENT
io_uring: simplify nxt propagation in io_queue_sqe
io_uring: simplify __io_queue_sqe()
fs/io_uring.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-)
Signature · 1 line
2.24.0
PATCH 1/3 io_uring: don't miss setting IO_WQ_WORK_CONCURRENT
Set IO_WQ_WORK_CONCURRENT for all REQ_F_FORCE_ASYNC requests, do that in that is also looks better.
--- fs/io_uring.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/io_uring.c +3 -7
@@ -1362,6 +1362,9 @@ static void io_prep_async_work(struct io_kiocb *req)io_req_init_async (req); id = req->work.identity; +if (req->flags &REQ_F_FORCE_ASYNC ) + req->work.flags |=IO_WQ_WORK_CONCURRENT ; +if (req->flags &REQ_F_ISREG ) {if (def->hash_reg_file || (ctx->flags &IORING_SETUP_IOPOLL ))io_wq_hash_work (&req->work,file_inode (req->file));
@@ -6265,13 +6268,6 @@ static void io_queue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,if (unlikely (ret)) goto fail_req; } - -/* -* Never try inline submit of IOSQE_ASYNC is set, go straight -* to async execution. -*/ -io_req_init_async (req); - req->work.flags |=IO_WQ_WORK_CONCURRENT ;io_queue_async_work (req); }else {if (sqe) {
Signature · 1 line
2.24.0
PATCH 2/3 io_uring: simplify nxt propagation in io_queue_sqe
In reply to Pavel BegunkovDon't overuse goto's, complex control flow doesn't make compilers happy and makes code harder to read.
--- fs/io_uring.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/io_uring.c +3 -7
@@ -6208,7 +6208,6 @@ static void __io_queue_sqe(struct io_kiocb *req, struct io_comp_state *cs)*/ if (ret == -EAGAIN && !(req->flags &REQ_F_NOWAIT )) {if (!io_arm_poll_handler (req)) { -punt:/* * Queued up for async execution, worker will release * submit reference when the iocb is actually submitted.
@@ -6237,12 +6236,9 @@ static void __io_queue_sqe(struct io_kiocb *req, struct io_comp_state *cs)if (nxt) { req = nxt; - -if (req->flags &REQ_F_FORCE_ASYNC ) { - linked_timeout =NULL ; - goto punt; - } - goto again; +if (!(req->flags &REQ_F_FORCE_ASYNC )) + goto again; +io_queue_async_work (req); } exit:if (old_creds)
Signature · 1 line
2.24.0
PATCH 3/3 io_uring: simplify __io_queue_sqe()
In reply to Pavel BegunkovRestructure __io_queue_sqe() so it follows simple if/else if/else control flow. It's more readable and removes extra goto/labels.
--- fs/io_uring.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
fs/io_uring.c +11 -17
@@ -6182,7 +6182,6 @@ static struct io_kiocb *io_prep_linked_timeout(struct io_kiocb *req)static void __io_queue_sqe (struct io_kiocb *req,struct io_comp_state *cs) {struct io_kiocb *linked_timeout; -struct io_kiocb *nxt;const struct cred *old_creds =NULL ;int ret;
@@ -6217,30 +6216,25 @@ static void __io_queue_sqe(struct io_kiocb *req, struct io_comp_state *cs)if (linked_timeout)io_queue_linked_timeout (linked_timeout); - goto exit; - } + }else if (likely (!ret)) { +/* drop submission reference */ + req =io_put_req_find_next (req); +if (linked_timeout) +io_queue_linked_timeout (linked_timeout); -if (unlikely (ret)) { +if (req) { +if (!(req->flags &REQ_F_FORCE_ASYNC )) + goto again; +io_queue_async_work (req); + } + }else {/* un-prep timeout, so it'll be killed as any other linked */ req->flags &= ~REQ_F_LINK_TIMEOUT ;req_set_fail_links (req);io_put_req (req);io_req_complete (req, ret); - goto exit; } -/* drop submission reference */ - nxt =io_put_req_find_next (req); -if (linked_timeout) -io_queue_linked_timeout (linked_timeout); - -if (nxt) { - req = nxt; -if (!(req->flags &REQ_F_FORCE_ASYNC )) - goto again; -io_queue_async_work (req); - } -exit:if (old_creds)revert_creds (old_creds); }
Signature · 1 line
2.24.0