From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>,
[email protected], [email protected]
Subject: [PATCH v2 03/13] io_uring: don't put nodes under spinlocks
Date: Tue, 4 Apr 2023 13:39:47 +0100 [thread overview]
Message-ID: <d5b87a5f31270dade6805f7acafc4cc34b84b241.1680576071.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
io_req_put_rsrc() doesn't need any locking, so move it out of
a spinlock section in __io_req_complete_post() and adjust helpers.
Signed-off-by: Pavel Begunkov <[email protected]>
---
io_uring/io_uring.c | 7 +++++--
io_uring/rsrc.h | 6 +++---
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index a0b64831c455..596af20cddb4 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -970,6 +970,7 @@ bool io_aux_cqe(struct io_ring_ctx *ctx, bool defer, u64 user_data, s32 res, u32
static void __io_req_complete_post(struct io_kiocb *req)
{
struct io_ring_ctx *ctx = req->ctx;
+ struct io_rsrc_node *rsrc_node = NULL;
io_cq_lock(ctx);
if (!(req->flags & REQ_F_CQE_SKIP))
@@ -990,7 +991,7 @@ static void __io_req_complete_post(struct io_kiocb *req)
}
io_put_kbuf_comp(req);
io_dismantle_req(req);
- io_req_put_rsrc(req);
+ rsrc_node = req->rsrc_node;
/*
* Selected buffer deallocation in io_clean_op() assumes that
* we don't hold ->completion_lock. Clean them here to avoid
@@ -1001,6 +1002,8 @@ static void __io_req_complete_post(struct io_kiocb *req)
ctx->locked_free_nr++;
}
io_cq_unlock_post(ctx);
+
+ io_put_rsrc_node(rsrc_node);
}
void io_req_complete_post(struct io_kiocb *req, unsigned issue_flags)
@@ -1117,7 +1120,7 @@ __cold void io_free_req(struct io_kiocb *req)
{
struct io_ring_ctx *ctx = req->ctx;
- io_req_put_rsrc(req);
+ io_put_rsrc_node(req->rsrc_node);
io_dismantle_req(req);
io_put_task_remote(req->task, 1);
diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h
index 950535e2b9f4..8164777279ba 100644
--- a/io_uring/rsrc.h
+++ b/io_uring/rsrc.h
@@ -115,10 +115,10 @@ static inline void io_rsrc_put_node(struct io_rsrc_node *node, int nr)
io_rsrc_node_ref_zero(node);
}
-static inline void io_req_put_rsrc(struct io_kiocb *req)
+static inline void io_put_rsrc_node(struct io_rsrc_node *node)
{
- if (req->rsrc_node)
- io_rsrc_put_node(req->rsrc_node, 1);
+ if (node)
+ io_rsrc_put_node(node, 1);
}
static inline void io_req_put_rsrc_locked(struct io_kiocb *req,
--
2.39.1
next prev parent reply other threads:[~2023-04-04 12:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-04 12:39 [PATCH v2 00/13] optimise registered buffer/file updates Pavel Begunkov
2023-04-04 12:39 ` [PATCH v2 01/13] io_uring/rsrc: use non-pcpu refcounts for nodes Pavel Begunkov
2023-04-04 12:39 ` [PATCH v2 02/13] io_uring/rsrc: keep cached refs per node Pavel Begunkov
2023-04-04 12:39 ` Pavel Begunkov [this message]
2023-04-04 12:39 ` [PATCH v2 04/13] io_uring: io_free_req() via tw Pavel Begunkov
2023-04-04 12:39 ` [PATCH v2 05/13] io_uring/rsrc: protect node refs with uring_lock Pavel Begunkov
2023-04-04 12:39 ` [PATCH v2 06/13] io_uring/rsrc: kill rsrc_ref_lock Pavel Begunkov
2023-04-04 12:39 ` [PATCH v2 07/13] io_uring/rsrc: rename rsrc_list Pavel Begunkov
2023-04-04 12:39 ` [PATCH v2 08/13] io_uring/rsrc: optimise io_rsrc_put allocation Pavel Begunkov
2023-04-04 12:39 ` [PATCH v2 09/13] io_uring/rsrc: don't offload node free Pavel Begunkov
2023-04-04 12:39 ` [PATCH v2 10/13] io_uring/rsrc: cache struct io_rsrc_node Pavel Begunkov
2023-04-04 12:39 ` [PATCH v2 11/13] io_uring/rsrc: add lockdep sanity checks Pavel Begunkov
2023-04-04 12:39 ` [PATCH v2 12/13] io_uring/rsrc: optimise io_rsrc_data refcounting Pavel Begunkov
2023-04-04 12:39 ` [PATCH v2 13/13] io_uring/rsrc: add custom limit for node caching Pavel Begunkov
2023-04-04 15:30 ` [PATCH v2 00/13] optimise registered buffer/file updates Jens Axboe
2023-04-04 15:33 ` 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=d5b87a5f31270dade6805f7acafc4cc34b84b241.1680576071.git.asml.silence@gmail.com \
[email protected] \
[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