Skip to content

Commit

Permalink
t/io_uring: only load tail once per reap loop
Browse files Browse the repository at this point in the history
It'll never change with the settings that t/io_uring uses to setup the
ring - and even if it could, it's still cheaper to just read the tail
once per reap.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
axboe committed Sep 30, 2024
1 parent fef1936 commit b46877e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions t/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,14 +699,15 @@ static int reap_events_uring(struct submitter *s)
{
struct io_cq_ring *ring = &s->cq_ring;
struct io_uring_cqe *cqe;
unsigned head, reaped = 0;
unsigned tail, head, reaped = 0;
int last_idx = -1, stat_nr = 0;

head = *ring->head;
tail = atomic_load_acquire(ring->tail);
do {
struct file *f;

if (head == atomic_load_acquire(ring->tail))
if (head == tail)
break;
cqe = &ring->cqes[head & cq_ring_mask];
if (!do_nop) {
Expand Down Expand Up @@ -755,16 +756,17 @@ static int reap_events_uring_pt(struct submitter *s)
{
struct io_cq_ring *ring = &s->cq_ring;
struct io_uring_cqe *cqe;
unsigned head, reaped = 0;
unsigned head, tail, reaped = 0;
int last_idx = -1, stat_nr = 0;
unsigned index;
int fileno;

head = *ring->head;
tail = atomic_load_acquire(ring->tail);
do {
struct file *f;

if (head == atomic_load_acquire(ring->tail))
if (head == tail)
break;
index = head & cq_ring_mask;
cqe = &ring->cqes[index << 1];
Expand Down

0 comments on commit b46877e

Please sign in to comment.