io_uring: move min_events sanitisation
iopoll and normal waiting already duplicate min_completion truncation, so move them inside the corresponding routines. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/254adb289cc04638f25d746a7499260fa89a179e.1742829388.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>pull/1188/head
parent
d73acd7af3
commit
816619782b
|
|
@ -1505,11 +1505,13 @@ static __cold void io_iopoll_try_reap_events(struct io_ring_ctx *ctx)
|
|||
mutex_unlock(&ctx->uring_lock);
|
||||
}
|
||||
|
||||
static int io_iopoll_check(struct io_ring_ctx *ctx, long min_events)
|
||||
static int io_iopoll_check(struct io_ring_ctx *ctx, unsigned int min_events)
|
||||
{
|
||||
unsigned int nr_events = 0;
|
||||
unsigned long check_cq;
|
||||
|
||||
min_events = min(min_events, ctx->cq_entries);
|
||||
|
||||
lockdep_assert_held(&ctx->uring_lock);
|
||||
|
||||
if (!io_allowed_run_tw(ctx))
|
||||
|
|
@ -2537,6 +2539,8 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, u32 flags,
|
|||
ktime_t start_time;
|
||||
int ret;
|
||||
|
||||
min_events = min_t(int, min_events, ctx->cq_entries);
|
||||
|
||||
if (!io_allowed_run_tw(ctx))
|
||||
return -EEXIST;
|
||||
if (io_local_work_pending(ctx))
|
||||
|
|
@ -3420,22 +3424,16 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
|
|||
mutex_lock(&ctx->uring_lock);
|
||||
iopoll_locked:
|
||||
ret2 = io_validate_ext_arg(ctx, flags, argp, argsz);
|
||||
if (likely(!ret2)) {
|
||||
min_complete = min(min_complete,
|
||||
ctx->cq_entries);
|
||||
if (likely(!ret2))
|
||||
ret2 = io_iopoll_check(ctx, min_complete);
|
||||
}
|
||||
mutex_unlock(&ctx->uring_lock);
|
||||
} else {
|
||||
struct ext_arg ext_arg = { .argsz = argsz };
|
||||
|
||||
ret2 = io_get_ext_arg(ctx, flags, argp, &ext_arg);
|
||||
if (likely(!ret2)) {
|
||||
min_complete = min(min_complete,
|
||||
ctx->cq_entries);
|
||||
if (likely(!ret2))
|
||||
ret2 = io_cqring_wait(ctx, min_complete, flags,
|
||||
&ext_arg);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue