Commit 87a115fb authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: force_nonspin

We don't really need to pass the number of requests to complete into
io_do_iopoll(), a flag whether to enforce non-spin mode is enough.

Should be straightforward, maybe except io_iopoll_check(). We pass !min
there, because we do never enter with the number of already reaped
requests is larger than the specified @min, apart from the first
iteration, where nr_events is 0 and so the final check should be
identical.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/782b39d1d8ec584eae15bca0a1feb6f0571fe5b8.1632516769.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 6878b40e
...@@ -2453,7 +2453,7 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events, ...@@ -2453,7 +2453,7 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events,
} }
static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events, static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events,
long min) bool force_nonspin)
{ {
struct io_kiocb *req, *tmp; struct io_kiocb *req, *tmp;
unsigned int poll_flags = BLK_POLL_NOSLEEP; unsigned int poll_flags = BLK_POLL_NOSLEEP;
...@@ -2462,9 +2462,9 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events, ...@@ -2462,9 +2462,9 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events,
/* /*
* Only spin for completions if we don't have multiple devices hanging * Only spin for completions if we don't have multiple devices hanging
* off our complete list, and we're under the requested amount. * off our complete list.
*/ */
if (ctx->poll_multi_queue || *nr_events >= min) if (ctx->poll_multi_queue || force_nonspin)
poll_flags |= BLK_POLL_ONESHOT; poll_flags |= BLK_POLL_ONESHOT;
list_for_each_entry_safe(req, tmp, &ctx->iopoll_list, inflight_entry) { list_for_each_entry_safe(req, tmp, &ctx->iopoll_list, inflight_entry) {
...@@ -2516,7 +2516,7 @@ static void io_iopoll_try_reap_events(struct io_ring_ctx *ctx) ...@@ -2516,7 +2516,7 @@ static void io_iopoll_try_reap_events(struct io_ring_ctx *ctx)
while (!list_empty(&ctx->iopoll_list)) { while (!list_empty(&ctx->iopoll_list)) {
unsigned int nr_events = 0; unsigned int nr_events = 0;
io_do_iopoll(ctx, &nr_events, 0); io_do_iopoll(ctx, &nr_events, true);
/* let it sleep and repeat later if can't complete a request */ /* let it sleep and repeat later if can't complete a request */
if (nr_events == 0) if (nr_events == 0)
...@@ -2578,7 +2578,7 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, long min) ...@@ -2578,7 +2578,7 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, long min)
list_empty(&ctx->iopoll_list)) list_empty(&ctx->iopoll_list))
break; break;
} }
ret = io_do_iopoll(ctx, &nr_events, min); ret = io_do_iopoll(ctx, &nr_events, !min);
} while (!ret && nr_events < min && !need_resched()); } while (!ret && nr_events < min && !need_resched());
out: out:
mutex_unlock(&ctx->uring_lock); mutex_unlock(&ctx->uring_lock);
...@@ -7347,7 +7347,7 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries) ...@@ -7347,7 +7347,7 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
mutex_lock(&ctx->uring_lock); mutex_lock(&ctx->uring_lock);
if (!list_empty(&ctx->iopoll_list)) if (!list_empty(&ctx->iopoll_list))
io_do_iopoll(ctx, &nr_events, 0); io_do_iopoll(ctx, &nr_events, true);
/* /*
* Don't submit if refs are dying, good for io_uring_register(), * Don't submit if refs are dying, good for io_uring_register(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment