io_uring: don't set TASK_RUNNING in local tw runner
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 9 Jan 2023 14:46:05 +0000 (14:46 +0000)
committerJens Axboe <axboe@kernel.dk>
Sun, 29 Jan 2023 22:17:40 +0000 (15:17 -0700)
The CQ waiting loop sets TASK_RUNNING before trying to execute
task_work, no need to repeat it in io_run_local_work().

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/9d9422c429ef3f9457b4f4b8288bf4789564f33b.1673274244.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c

index 5e1a0845e4b6e0272c58a983bc68128c3b80f315..e61e2a0f23b12839fbc78d409686ccac9a68e599 100644 (file)
@@ -1339,11 +1339,9 @@ again:
 
 int io_run_local_work(struct io_ring_ctx *ctx)
 {
-       bool locked;
+       bool locked = mutex_trylock(&ctx->uring_lock);
        int ret;
 
-       __set_current_state(TASK_RUNNING);
-       locked = mutex_trylock(&ctx->uring_lock);
        ret = __io_run_local_work(ctx, &locked);
        if (locked)
                mutex_unlock(&ctx->uring_lock);
@@ -2453,6 +2451,7 @@ static int io_wake_function(struct wait_queue_entry *curr, unsigned int mode,
 int io_run_task_work_sig(struct io_ring_ctx *ctx)
 {
        if (!llist_empty(&ctx->work_llist)) {
+               __set_current_state(TASK_RUNNING);
                if (io_run_local_work(ctx) > 0)
                        return 1;
        }