* [PATCH 1/3] io_uring: don't miss setting IO_WQ_WORK_CONCURRENT
2020-10-22 15:47 [PATCH 0/3] __io_queue_sqe() cleanups Pavel Begunkov
@ 2020-10-22 15:47 ` Pavel Begunkov
2020-10-22 15:47 ` [PATCH 2/3] io_uring: simplify nxt propagation in io_queue_sqe Pavel Begunkov
2020-10-22 15:47 ` [PATCH 3/3] io_uring: simplify __io_queue_sqe() Pavel Begunkov
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2020-10-22 15:47 UTC (permalink / raw)
To: Jens Axboe, io-uring
Set IO_WQ_WORK_CONCURRENT for all REQ_F_FORCE_ASYNC requests, do that in
that is also looks better.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 8e48e47906ba..9aeaa6f4a593 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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) {
--
2.24.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] io_uring: simplify nxt propagation in io_queue_sqe
2020-10-22 15:47 [PATCH 0/3] __io_queue_sqe() cleanups Pavel Begunkov
2020-10-22 15:47 ` [PATCH 1/3] io_uring: don't miss setting IO_WQ_WORK_CONCURRENT Pavel Begunkov
@ 2020-10-22 15:47 ` Pavel Begunkov
2020-10-22 15:47 ` [PATCH 3/3] io_uring: simplify __io_queue_sqe() Pavel Begunkov
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2020-10-22 15:47 UTC (permalink / raw)
To: Jens Axboe, io-uring
Don't overuse goto's, complex control flow doesn't make compilers happy
and makes code harder to read.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 9aeaa6f4a593..05b30212d9e6 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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)
--
2.24.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] io_uring: simplify __io_queue_sqe()
2020-10-22 15:47 [PATCH 0/3] __io_queue_sqe() cleanups Pavel Begunkov
2020-10-22 15:47 ` [PATCH 1/3] io_uring: don't miss setting IO_WQ_WORK_CONCURRENT Pavel Begunkov
2020-10-22 15:47 ` [PATCH 2/3] io_uring: simplify nxt propagation in io_queue_sqe Pavel Begunkov
@ 2020-10-22 15:47 ` Pavel Begunkov
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2020-10-22 15:47 UTC (permalink / raw)
To: Jens Axboe, io-uring
Restructure __io_queue_sqe() so it follows simple if/else if/else
control flow. It's more readable and removes extra goto/labels.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 05b30212d9e6..754363ff3ad6 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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);
}
--
2.24.0
^ permalink raw reply related [flat|nested] 4+ messages in thread