Commit a566c556 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: remove dependency on ring->sq/cq_entries

We have numbers of {sq,cq} entries cached in ctx, don't look up them in
user-shared rings as 1) it may fetch additional cacheline 2) user may
change it and so it's always error prone.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/745d31bc2da41283ddd0489ef784af5c8d6310e9.1621201931.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent b13a8918
...@@ -1356,7 +1356,7 @@ static inline bool io_sqring_full(struct io_ring_ctx *ctx) ...@@ -1356,7 +1356,7 @@ static inline bool io_sqring_full(struct io_ring_ctx *ctx)
{ {
struct io_rings *r = ctx->rings; struct io_rings *r = ctx->rings;
return READ_ONCE(r->sq.tail) - ctx->cached_sq_head == r->sq_ring_entries; return READ_ONCE(r->sq.tail) - ctx->cached_sq_head == ctx->sq_entries;
} }
static inline unsigned int __io_cqring_events(struct io_ring_ctx *ctx) static inline unsigned int __io_cqring_events(struct io_ring_ctx *ctx)
...@@ -1374,7 +1374,7 @@ static inline struct io_uring_cqe *io_get_cqring(struct io_ring_ctx *ctx) ...@@ -1374,7 +1374,7 @@ static inline struct io_uring_cqe *io_get_cqring(struct io_ring_ctx *ctx)
* control dependency is enough as we're using WRITE_ONCE to * control dependency is enough as we're using WRITE_ONCE to
* fill the cq entry * fill the cq entry
*/ */
if (__io_cqring_events(ctx) == rings->cq_ring_entries) if (__io_cqring_events(ctx) == ctx->cq_entries)
return NULL; return NULL;
tail = ctx->cached_cq_tail++; tail = ctx->cached_cq_tail++;
...@@ -1427,11 +1427,10 @@ static void io_cqring_ev_posted_iopoll(struct io_ring_ctx *ctx) ...@@ -1427,11 +1427,10 @@ static void io_cqring_ev_posted_iopoll(struct io_ring_ctx *ctx)
/* Returns true if there are no backlogged entries after the flush */ /* Returns true if there are no backlogged entries after the flush */
static bool __io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force) static bool __io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force)
{ {
struct io_rings *rings = ctx->rings;
unsigned long flags; unsigned long flags;
bool all_flushed, posted; bool all_flushed, posted;
if (!force && __io_cqring_events(ctx) == rings->cq_ring_entries) if (!force && __io_cqring_events(ctx) == ctx->cq_entries)
return false; return false;
posted = false; posted = false;
......
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