summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-02-06 17:54:54 -0700
committerJens Axboe <axboe@kernel.dk>2020-02-06 17:54:54 -0700
commitdd15d761d0ec015661f8c779904c7198704437b1 (patch)
treeb0c05253bd9a89bd6e3daa44102cb6d26fd22718
parent931c523233e4aa3665b0c827425453cc98f49a44 (diff)
downloadliburing-dd15d761d0ec015661f8c779904c7198704437b1.tar.gz
liburing-dd15d761d0ec015661f8c779904c7198704437b1.tar.bz2
io_uring_sq_ready: check shared head for SQPOLL ring
If the ring is using SQPOLL, then the kernel side is updating the ring head without us knowing. Ensure we load it and don't use the local cache. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/include/liburing.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/include/liburing.h b/src/include/liburing.h
index b549ea7..2f1e968 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -415,7 +415,9 @@ static inline void io_uring_prep_epoll_ctl(struct io_uring_sqe *sqe, int epfd,
static inline unsigned io_uring_sq_ready(struct io_uring *ring)
{
- return ring->sq.sqe_tail - ring->sq.sqe_head;
+ if (!(ring->flags & IORING_SETUP_SQPOLL))
+ return ring->sq.sqe_tail - ring->sq.sqe_head;
+ return ring->sq.sqe_tail - *ring->sq.khead;
}
static inline unsigned io_uring_sq_space_left(struct io_uring *ring)