liburing.h: avoid OOL round trip in io_uring_peek_cqe() on empty CQ

With the CQ empty, io_uring_peek_cqe() called into __io_uring_get_cqe()
just to do a second full peek and conclude -EAGAIN, costing a function
call, a redundant acquire load of the CQ tail, and the get_data setup
on every poll. That's wasted work for spin-poll style users.

Return -EAGAIN directly if the peek found nothing and there's nothing
the kernel could flush to the CQ: no IOPOLL completions to reap, no
overflown CQEs, and no pending task work. Those cases, and a peek that
consumed an internal timeout CQE, still take the slow path as before.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 file changed