public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH for-next 6/7] io_uring: refactor tctx_task_work
Date: Mon, 23 Jan 2023 14:37:18 +0000	[thread overview]
Message-ID: <d06592d91e3e7559e7a4dbb8907d110863008dc7.1674484266.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Merge almost identical sections of tctx_task_work(), this will make code
modifications later easier and also inlines handle_tw_list().

Signed-off-by: Pavel Begunkov <[email protected]>
---
 io_uring/io_uring.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index faada7e76f2d..586e70f686ce 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1166,7 +1166,7 @@ static unsigned int handle_tw_list(struct llist_node *node,
 {
 	unsigned int count = 0;
 
-	while (node != last) {
+	while (node && node != last) {
 		struct llist_node *next = node->next;
 		struct io_kiocb *req = container_of(node, struct io_kiocb,
 						    io_task_work.node);
@@ -1226,7 +1226,7 @@ void tctx_task_work(struct callback_head *cb)
 						  task_work);
 	struct llist_node fake = {};
 	struct llist_node *node;
-	unsigned int loops = 1;
+	unsigned int loops = 0;
 	unsigned int count;
 
 	if (unlikely(current->flags & PF_EXITING)) {
@@ -1234,15 +1234,12 @@ void tctx_task_work(struct callback_head *cb)
 		return;
 	}
 
-	node = io_llist_xchg(&tctx->task_list, &fake);
-	count = handle_tw_list(node, &ctx, &uring_locked, NULL);
-	node = io_llist_cmpxchg(&tctx->task_list, &fake, NULL);
-	while (node != &fake) {
+	do {
 		loops++;
 		node = io_llist_xchg(&tctx->task_list, &fake);
 		count += handle_tw_list(node, &ctx, &uring_locked, &fake);
 		node = io_llist_cmpxchg(&tctx->task_list, &fake, NULL);
-	}
+	} while (node != &fake);
 
 	ctx_flush_and_put(ctx, &uring_locked);
 
-- 
2.38.1


  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 ` [PATCH for-next 5/7] io_uring: refactor io_put_task helpers Pavel Begunkov
2023-01-23 14:37 ` Pavel Begunkov [this message]
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=d06592d91e3e7559e7a4dbb8907d110863008dc7.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