Skip to content

Commit

Permalink
io_uring: cap io_sqring_entries() at SQ ring size
Browse files Browse the repository at this point in the history
We already do this manually for the !SQPOLL case, do it in general and
we can also dump the ugly min3() in io_submit_sqes().

Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
axboe committed Apr 3, 2023
1 parent 2ad5793 commit e3ef728
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion io_uring/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -2434,7 +2434,7 @@ int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
if (unlikely(!entries))
return 0;
/* make sure SQ entry isn't read before tail */
ret = left = min3(nr, ctx->sq_entries, entries);
ret = left = min(nr, entries);
io_get_task_refs(left);
io_submit_state_start(&ctx->submit_state, left);

Expand Down
4 changes: 3 additions & 1 deletion io_uring/io_uring.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,11 @@ static inline bool io_sqring_full(struct io_ring_ctx *ctx)
static inline unsigned int io_sqring_entries(struct io_ring_ctx *ctx)
{
struct io_rings *rings = ctx->rings;
unsigned int entries;

/* make sure SQ entry isn't read before tail */
return smp_load_acquire(&rings->sq.tail) - ctx->cached_sq_head;
entries = smp_load_acquire(&rings->sq.tail) - ctx->cached_sq_head;
return min(entries, ctx->sq_entries);
}

static inline int io_run_task_work(void)
Expand Down

0 comments on commit e3ef728

Please sign in to comment.