diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-02-04 13:51:57 +0000 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-02-04 08:05:46 -0700 |
commit | c1d5a224683b333ddbe278e455d639ccd4f5ca2b (patch) | |
tree | 5ec3e698f2b96e7e835b9473f52299c28f3f415f /fs/io_uring.c | |
parent | 9936c7c2bc76a0b2276f6d19de6d1d92f03deeab (diff) | |
download | lwn-c1d5a224683b333ddbe278e455d639ccd4f5ca2b.tar.gz lwn-c1d5a224683b333ddbe278e455d639ccd4f5ca2b.zip |
io_uring: refactor scheduling in io_cqring_wait
schedule_timeout() with timeout=MAX_SCHEDULE_TIMEOUT is guaranteed to
work just as schedule(), so instead of hand-coding it based on arguments
always use the timeout version and simplify code.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r-- | fs/io_uring.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index a750c504366d..5b735635b8f0 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7213,9 +7213,8 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, .to_wait = min_events, }; struct io_rings *rings = ctx->rings; - struct timespec64 ts; - signed long timeout = 0; - int ret = 0; + signed long timeout = MAX_SCHEDULE_TIMEOUT; + int ret; do { io_cqring_overflow_flush(ctx, false, NULL, NULL); @@ -7239,6 +7238,8 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, } if (uts) { + struct timespec64 ts; + if (get_timespec64(&ts, uts)) return -EFAULT; timeout = timespec64_to_jiffies(&ts); @@ -7264,14 +7265,10 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, finish_wait(&ctx->wait, &iowq.wq); continue; } - if (uts) { - timeout = schedule_timeout(timeout); - if (timeout == 0) { - ret = -ETIME; - break; - } - } else { - schedule(); + timeout = schedule_timeout(timeout); + if (timeout == 0) { + ret = -ETIME; + break; } } while (1); finish_wait(&ctx->wait, &iowq.wq); |