Skip to content

Commit d106b88

Browse files
committed
examples/zcrx: add is_full helper for RQ
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
1 parent a62eb24 commit d106b88

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

examples/zcrx.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,11 @@ static unsigned rq_nr_queued(struct io_uring_zcrx_rq *rq)
400400
return rq->rq_tail - io_uring_smp_load_acquire(rq->khead);
401401
}
402402

403+
static bool rq_is_full(struct io_uring_zcrx_rq *rq)
404+
{
405+
return rq_nr_queued(rq) == rq->ring_entries;
406+
}
407+
403408
static inline void fill_rqe(const struct io_uring_cqe *cqe,
404409
struct io_uring_zcrx_rqe *rqe)
405410
{
@@ -430,7 +435,7 @@ static bool flush_refill_queue(struct io_uring *ring,
430435
}
431436

432437
/* should never happen */
433-
if (rq_nr_queued(rq_ring) == rq_ring->ring_entries)
438+
if (rq_is_full(rq_ring))
434439
t_error(1, 0, "Couldn't flush refill ring\n");
435440
return true;
436441
}
@@ -442,8 +447,7 @@ static void return_buffer(struct io_uring *ring,
442447
struct io_uring_zcrx_rqe *rqe;
443448
unsigned rq_mask;
444449

445-
if (rq_nr_queued(rq_ring) == rq_ring->ring_entries &&
446-
!flush_refill_queue(ring, rq_ring)) {
450+
if (rq_is_full(rq_ring) && !flush_refill_queue(ring, rq_ring)) {
447451
printf("RQ is full, drop the buffer\n");
448452
return;
449453
}

0 commit comments

Comments
 (0)