]> git.itanic.dy.fi Git - linux-stable/commitdiff
io_uring: don't save/restore iowait state
authorJens Axboe <axboe@kernel.dk>
Mon, 11 Mar 2024 19:30:43 +0000 (13:30 -0600)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:17:31 +0000 (18:17 -0400)
[ Upstream commit 6f0974eccbf78baead1735722c4f1ee3eb9422cd ]

This kind of state is per-syscall, and since we're doing the waiting off
entering the io_uring_enter(2) syscall, there's no way that iowait can
already be set for this case. Simplify it by setting it if we need to,
and always clearing it to 0 when done.

Fixes: 7b72d661f1f2 ("io_uring: gate iowait schedule on having pending requests")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
io_uring/io_uring.c

index 39dfb83dc9fc4dba74e6ed9b0e6ced765ec098b6..030cc930d1c6a6b014d7ae5978063ab6a2a293fc 100644 (file)
@@ -2527,7 +2527,7 @@ static bool current_pending_io(void)
 static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
                                          struct io_wait_queue *iowq)
 {
-       int io_wait, ret;
+       int ret;
 
        if (unlikely(READ_ONCE(ctx->check_cq)))
                return 1;
@@ -2545,7 +2545,6 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
         * can take into account that the task is waiting for IO - turns out
         * to be important for low QD IO.
         */
-       io_wait = current->in_iowait;
        if (current_pending_io())
                current->in_iowait = 1;
        ret = 0;
@@ -2553,7 +2552,7 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
                schedule();
        else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS))
                ret = -ETIME;
-       current->in_iowait = io_wait;
+       current->in_iowait = 0;
        return ret;
 }