From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH v2 1/9] io_uring: share completion list w/ per-op space
Date: Mon, 13 Jul 2020 23:37:08 +0300 [thread overview]
Message-ID: <a315572342c11717bac4e3f580c8acf47a460d30.1594670798.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Calling io_req_complete(req) means that the request is done, and there
nothing left but to clean it up. That also means that per-op data
after that should not be used, so we're free to reuse it in completion
path, e.g. to store overflow_list as done in this patch.
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 0b9c0333d8c0..b60307a69599 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -487,6 +487,11 @@ struct io_statx {
struct statx __user *buffer;
};
+struct io_completion {
+ struct file *file;
+ struct list_head list;
+};
+
struct io_async_connect {
struct sockaddr_storage address;
};
@@ -621,6 +626,8 @@ struct io_kiocb {
struct io_splice splice;
struct io_provide_buf pbuf;
struct io_statx statx;
+ /* use only after cleaning per-op data, see io_clean_op() */
+ struct io_completion compl;
};
struct io_async_ctx *io;
@@ -895,7 +902,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
static int io_grab_files(struct io_kiocb *req);
static void io_complete_rw_common(struct kiocb *kiocb, long res,
struct io_comp_state *cs);
-static void io_cleanup_req(struct io_kiocb *req);
+static void __io_clean_op(struct io_kiocb *req);
static int io_file_get(struct io_submit_state *state, struct io_kiocb *req,
int fd, struct file **out_file, bool fixed);
static void __io_queue_sqe(struct io_kiocb *req,
@@ -935,6 +942,12 @@ static void io_get_req_task(struct io_kiocb *req)
req->flags |= REQ_F_TASK_PINNED;
}
+static inline void io_clean_op(struct io_kiocb *req)
+{
+ if (req->flags & REQ_F_NEED_CLEANUP)
+ __io_clean_op(req);
+}
+
/* not idempotent -- it doesn't clear REQ_F_TASK_PINNED */
static void __io_put_req_task(struct io_kiocb *req)
{
@@ -1412,8 +1425,8 @@ static void io_submit_flush_completions(struct io_comp_state *cs)
while (!list_empty(&cs->list)) {
struct io_kiocb *req;
- req = list_first_entry(&cs->list, struct io_kiocb, list);
- list_del(&req->list);
+ req = list_first_entry(&cs->list, struct io_kiocb, compl.list);
+ list_del(&req->compl.list);
__io_cqring_fill_event(req, req->result, req->cflags);
if (!(req->flags & REQ_F_LINK_HEAD)) {
req->flags |= REQ_F_COMP_LOCKED;
@@ -1438,9 +1451,10 @@ static void __io_req_complete(struct io_kiocb *req, long res, unsigned cflags,
io_cqring_add_event(req, res, cflags);
io_put_req(req);
} else {
+ io_clean_op(req);
req->result = res;
req->cflags = cflags;
- list_add_tail(&req->list, &cs->list);
+ list_add_tail(&req->compl.list, &cs->list);
if (++cs->nr >= 32)
io_submit_flush_completions(cs);
}
@@ -1514,8 +1528,7 @@ static inline void io_put_file(struct io_kiocb *req, struct file *file,
static void io_dismantle_req(struct io_kiocb *req)
{
- if (req->flags & REQ_F_NEED_CLEANUP)
- io_cleanup_req(req);
+ io_clean_op(req);
if (req->io)
kfree(req->io);
@@ -5380,7 +5393,7 @@ static int io_req_defer(struct io_kiocb *req, const struct io_uring_sqe *sqe)
return -EIOCBQUEUED;
}
-static void io_cleanup_req(struct io_kiocb *req)
+static void __io_clean_op(struct io_kiocb *req)
{
struct io_async_ctx *io = req->io;
--
2.24.0
next prev parent reply other threads:[~2020-07-13 20:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-13 20:37 [PATCH v2 0/9] scrap 24 bytes from io_kiocb Pavel Begunkov
2020-07-13 20:37 ` Pavel Begunkov [this message]
2020-07-13 20:37 ` [PATCH v2 2/9] io_uring: rename ctx->poll into ctx->iopoll Pavel Begunkov
2020-07-13 20:37 ` [PATCH v2 3/9] io_uring: use inflight_entry list for iopoll'ing Pavel Begunkov
2020-07-13 20:37 ` [PATCH v2 4/9] io_uring: use completion list for CQ overflow Pavel Begunkov
2020-07-13 20:37 ` [PATCH v2 5/9] io_uring: add req->timeout.list Pavel Begunkov
2020-07-13 20:37 ` [PATCH v2 6/9] io_uring: remove init for unused list Pavel Begunkov
2020-07-13 20:37 ` [PATCH v2 7/9] io_uring: use non-intrusive list for defer Pavel Begunkov
2020-07-13 20:37 ` [PATCH v2 8/9] io_uring: remove sequence from io_kiocb Pavel Begunkov
2020-07-13 20:37 ` [PATCH v2 9/9] io_uring: place cflags into completion data Pavel Begunkov
2020-07-13 21:10 ` [PATCH v2 0/9] scrap 24 bytes from io_kiocb Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a315572342c11717bac4e3f580c8acf47a460d30.1594670798.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox