io_uring: clamp to_submit in io_submit_sqes()
Make io_submit_sqes() to clamp @to_submit itself. It removes duplicated code and prepares for following changes. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
8110c1a621
commit
9ef4f12489
@ -4577,6 +4577,8 @@ static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr,
|
|||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nr = min(nr, ctx->sq_entries);
|
||||||
|
|
||||||
if (!percpu_ref_tryget_many(&ctx->refs, nr))
|
if (!percpu_ref_tryget_many(&ctx->refs, nr))
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
|
|
||||||
@ -4751,7 +4753,6 @@ static int io_sq_thread(void *data)
|
|||||||
ctx->rings->sq_flags &= ~IORING_SQ_NEED_WAKEUP;
|
ctx->rings->sq_flags &= ~IORING_SQ_NEED_WAKEUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
to_submit = min(to_submit, ctx->sq_entries);
|
|
||||||
mutex_lock(&ctx->uring_lock);
|
mutex_lock(&ctx->uring_lock);
|
||||||
ret = io_submit_sqes(ctx, to_submit, NULL, -1, &cur_mm, true);
|
ret = io_submit_sqes(ctx, to_submit, NULL, -1, &cur_mm, true);
|
||||||
mutex_unlock(&ctx->uring_lock);
|
mutex_unlock(&ctx->uring_lock);
|
||||||
@ -6100,7 +6101,6 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
to_submit = min(to_submit, ctx->sq_entries);
|
|
||||||
mutex_lock(&ctx->uring_lock);
|
mutex_lock(&ctx->uring_lock);
|
||||||
/* already have mm, so io_submit_sqes() won't try to grab it */
|
/* already have mm, so io_submit_sqes() won't try to grab it */
|
||||||
cur_mm = ctx->sqo_mm;
|
cur_mm = ctx->sqo_mm;
|
||||||
|
Loading…
Reference in New Issue
Block a user