mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-03 20:34:23 -04:00
io_uring: further deduplicate #CQ events calc
Apparently, there is one more place hand coded calculation of number of CQ events in the ring. Use __io_cqring_events() helper in io_get_cqring() as well. Naturally, assembly stays identical. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
ec30e04ba4
commit
888aae2eed
@@ -1700,21 +1700,25 @@ static inline bool io_sqring_full(struct io_ring_ctx *ctx)
|
||||
return READ_ONCE(r->sq.tail) - ctx->cached_sq_head == r->sq_ring_entries;
|
||||
}
|
||||
|
||||
static inline unsigned int __io_cqring_events(struct io_ring_ctx *ctx)
|
||||
{
|
||||
return ctx->cached_cq_tail - READ_ONCE(ctx->rings->cq.head);
|
||||
}
|
||||
|
||||
static struct io_uring_cqe *io_get_cqring(struct io_ring_ctx *ctx)
|
||||
{
|
||||
struct io_rings *rings = ctx->rings;
|
||||
unsigned tail;
|
||||
|
||||
tail = ctx->cached_cq_tail;
|
||||
/*
|
||||
* writes to the cq entry need to come after reading head; the
|
||||
* control dependency is enough as we're using WRITE_ONCE to
|
||||
* fill the cq entry
|
||||
*/
|
||||
if (tail - READ_ONCE(rings->cq.head) == rings->cq_ring_entries)
|
||||
if (__io_cqring_events(ctx) == rings->cq_ring_entries)
|
||||
return NULL;
|
||||
|
||||
ctx->cached_cq_tail++;
|
||||
tail = ctx->cached_cq_tail++;
|
||||
return &rings->cqes[tail & ctx->cq_mask];
|
||||
}
|
||||
|
||||
@@ -1729,11 +1733,6 @@ static inline bool io_should_trigger_evfd(struct io_ring_ctx *ctx)
|
||||
return io_wq_current_is_worker();
|
||||
}
|
||||
|
||||
static inline unsigned __io_cqring_events(struct io_ring_ctx *ctx)
|
||||
{
|
||||
return ctx->cached_cq_tail - READ_ONCE(ctx->rings->cq.head);
|
||||
}
|
||||
|
||||
static void io_cqring_ev_posted(struct io_ring_ctx *ctx)
|
||||
{
|
||||
/* see waitqueue_active() comment */
|
||||
|
||||
Reference in New Issue
Block a user