From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH for-next 5/7] io_uring: refactor io_put_task helpers
Date: Mon, 23 Jan 2023 14:37:17 +0000 [thread overview]
Message-ID: <3bf92ebd594769d8a5d648472a8e335f2031d542.1674484266.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Add a helper for putting refs from the target task context, rename
__io_put_task() and add a couple of comments around. Use the remote
version for __io_req_complete_post(), the local is only needed for
__io_submit_flush_completions().
Signed-off-by: Pavel Begunkov <[email protected]>
---
io_uring/io_uring.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 8a99791a507a..faada7e76f2d 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -713,7 +713,8 @@ static void io_cqring_overflow_flush(struct io_ring_ctx *ctx)
io_cqring_do_overflow_flush(ctx);
}
-static void __io_put_task(struct task_struct *task, int nr)
+/* can be called by any task */
+static void io_put_task_remote(struct task_struct *task, int nr)
{
struct io_uring_task *tctx = task->io_uring;
@@ -723,13 +724,19 @@ static void __io_put_task(struct task_struct *task, int nr)
put_task_struct_many(task, nr);
}
+/* used by a task to put its own references */
+static void io_put_task_local(struct task_struct *task, int nr)
+{
+ task->io_uring->cached_refs += nr;
+}
+
/* must to be called somewhat shortly after putting a request */
static inline void io_put_task(struct task_struct *task, int nr)
{
if (likely(task == current))
- task->io_uring->cached_refs += nr;
+ io_put_task_local(task, nr);
else
- __io_put_task(task, nr);
+ io_put_task_remote(task, nr);
}
void io_task_refs_refill(struct io_uring_task *tctx)
@@ -982,7 +989,7 @@ static void __io_req_complete_post(struct io_kiocb *req)
* we don't hold ->completion_lock. Clean them here to avoid
* deadlocks.
*/
- io_put_task(req->task, 1);
+ io_put_task_remote(req->task, 1);
wq_list_add_head(&req->comp_list, &ctx->locked_free_list);
ctx->locked_free_nr++;
}
@@ -1105,7 +1112,7 @@ __cold void io_free_req(struct io_kiocb *req)
io_req_put_rsrc(req);
io_dismantle_req(req);
- io_put_task(req->task, 1);
+ io_put_task_remote(req->task, 1);
spin_lock(&ctx->completion_lock);
wq_list_add_head(&req->comp_list, &ctx->locked_free_list);
--
2.38.1
next prev parent reply other threads:[~2023-01-23 14:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-23 14:37 [PATCH for-next 0/7] normal tw optimisation + refactoring Pavel Begunkov
2023-01-23 14:37 ` [PATCH for-next 1/7] io_uring: use user visible tail in io_uring_poll() Pavel Begunkov
2023-01-23 18:25 ` Jens Axboe
2023-01-23 20:56 ` Pavel Begunkov
2023-01-23 21:09 ` Jens Axboe
2023-01-23 14:37 ` [PATCH for-next 2/7] io_uring: kill outdated comment about overflow flush Pavel Begunkov
2023-01-23 14:37 ` [PATCH for-next 3/7] io_uring: improve io_get_sqe Pavel Begunkov
2023-01-23 14:37 ` [PATCH for-next 4/7] io_uring: refactor req allocation Pavel Begunkov
2023-01-23 14:37 ` Pavel Begunkov [this message]
2023-01-23 14:37 ` [PATCH for-next 6/7] io_uring: refactor tctx_task_work Pavel Begunkov
2023-01-23 14:37 ` [PATCH for-next 7/7] io_uring: return normal tw run linking optimisation Pavel Begunkov
2023-01-23 21:14 ` [PATCH for-next 0/7] normal tw optimisation + refactoring 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=3bf92ebd594769d8a5d648472a8e335f2031d542.1674484266.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