From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 2/8] io_uring: refactor scheduling in io_cqring_wait
Date: Tue, 2 Feb 2021 00:21:40 +0000 [thread overview]
Message-ID: <0322df69e7171d3ad659dff4579687d629b4e16f.1612223953.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
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 <[email protected]>
---
fs/io_uring.c | 19 ++++++++-----------
1 file 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);
--
2.24.0
next prev parent reply other threads:[~2021-02-02 0:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 0:21 [PATCH 0/8] a second pack of 5.12 cleanups Pavel Begunkov
2021-02-02 0:21 ` [PATCH 1/8] io_uring: deduplicate core cancellations sequence Pavel Begunkov
2021-02-02 0:21 ` Pavel Begunkov [this message]
2021-02-02 0:21 ` [PATCH 3/8] io_uring: refactor io_cqring_wait Pavel Begunkov
2021-02-02 0:21 ` [PATCH 4/8] io_uring: refactor io_read for unsupported nowait Pavel Begunkov
2021-02-02 0:21 ` [PATCH 5/8] io_uring: further simplify do_read error parsing Pavel Begunkov
2021-02-02 0:21 ` [PATCH 6/8] io_uring: let io_setup_async_rw take care of iovec Pavel Begunkov
2021-02-02 0:21 ` [PATCH 7/8] io_uring: don't forget to adjust io_size Pavel Begunkov
2021-02-02 0:21 ` [PATCH 8/8] io_uring: inline io_read()'s iovec freeing Pavel Begunkov
2021-02-04 13:52 ` [PATCH 0/8] a second pack of 5.12 cleanups Pavel Begunkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0322df69e7171d3ad659dff4579687d629b4e16f.1612223953.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox