Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jorangreef/liburing into …
Browse files Browse the repository at this point in the history
…master

* 'master' of https://github.com/jorangreef/liburing:
  Fix io_uring_sq_ready() to use load acquire to read khead.
  • Loading branch information
axboe committed Sep 7, 2020
2 parents a25caac + 724d8dd commit 4b94563
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/include/liburing.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,13 @@ static inline void io_uring_prep_shutdown(struct io_uring_sqe *sqe, int fd,
*/
static inline unsigned io_uring_sq_ready(struct io_uring *ring)
{
/*
* Without a barrier, we could miss an update and think the SQ wasn't ready.
* We don't need the load acquire for non-SQPOLL since then we drive updates.
*/
if (ring->flags & IORING_SETUP_SQPOLL)
return ring->sq.sqe_tail - io_uring_smp_load_acquire(ring->sq.khead);

/* always use real head, to avoid losing sync for short submit */
return ring->sq.sqe_tail - *ring->sq.khead;
}
Expand Down

0 comments on commit 4b94563

Please sign in to comment.