io_uring: replace cmpxchg in fallback with xchg
authorPavel Begunkov <asml.silence@gmail.com>
Sun, 28 Feb 2021 22:04:54 +0000 (22:04 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 4 Mar 2021 13:37:14 +0000 (06:37 -0700)
io_run_ctx_fallback() can use xchg() instead of cmpxchg(). It's simpler
and faster.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index 62a73543ab8642c075cd9cabd9b9f7e9e905433a..57c7833ba62bec75787b35952421fd197a609a4b 100644 (file)
@@ -8484,15 +8484,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;