Skip to content

Commit

Permalink
io_uring: don't save/restore iowait state
Browse files Browse the repository at this point in the history
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: 7b72d66 ("io_uring: gate iowait schedule on having pending requests")
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Mar 11, 2024
1 parent 045395d commit 6f0974e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions io_uring/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -2539,7 +2539,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;
Expand All @@ -2557,15 +2557,14 @@ 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;
if (iowq->timeout == KTIME_MAX)
schedule();
else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS))
ret = -ETIME;
current->in_iowait = io_wait;
current->in_iowait = 0;
return ret;
}

Expand Down

0 comments on commit 6f0974e

Please sign in to comment.