public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 2/2] io_uring: replace cmpxchg in fallback with xchg
Date: Sun, 28 Feb 2021 22:04:54 +0000	[thread overview]
Message-ID: <446223e20253334e0bea08a0d21a42daba8d916c.1614549667.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

io_run_ctx_fallback() can use xchg() instead of cmpxchg(). It's faster
and faster.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 365e75b53a78..42b675939582 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -8489,15 +8489,11 @@ static int io_remove_personalities(int id, void *p, void *data)
 
 static bool io_run_ctx_fallback(struct io_ring_ctx *ctx)
 {
-	struct callback_head *work, *head, *next;
+	struct callback_head *work, *next;
 	bool executed = false;
 
 	do {
-		do {
-			head = NULL;
-			work = READ_ONCE(ctx->exit_task_work);
-		} while (cmpxchg(&ctx->exit_task_work, work, head) != work);
-
+		work = xchg(&ctx->exit_task_work, NULL);
 		if (!work)
 			break;
 
-- 
2.24.0


  parent reply	other threads:[~2021-02-28 22:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-28 22:04 [PATCH 5.12 0/2] task_work ctx refs fix + xchg cleanup Pavel Begunkov
2021-02-28 22:04 ` [PATCH 1/2] io_uring: fix __tctx_task_work() ctx race Pavel Begunkov
2021-02-28 22:04 ` Pavel Begunkov [this message]
2021-02-28 22:17 ` [PATCH 5.12 0/2] task_work ctx refs fix + xchg cleanup 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=446223e20253334e0bea08a0d21a42daba8d916c.1614549667.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