src/queue: add comment on why reading SQ->head for flush isn't atomic
This has come up at least two times, add a comment there to explain
exactly why the code is fine as-is.
Fixes:
@@ -225,6 +225,17 @@ int __io_uring_flush_sq(struct io_uring *ring)
*/
io_uring_smp_store_release(sq->ktail, ktail);
out:
+ /*
+ * This _may_ look problematic, as we're not supposed to be reading
+ * SQ->head without acquire semantics. When we're in SQPOLL mode, the
+ * kernel submitter could be updating this right now. For non-SQPOLL,
+ * task itself does it, and there's no potential face. But even for
+ * SQPOLL, the load is going to be potentially out-of-date the very
+ * instant it's done, regardless or whether or not it's done
+ * atomically. Worst case, we're going to be over-estimating what
+ * we can submit. The point is, we need to be able to deal with this
+ * situation regardless of any perceived atomicity.
+ */
return ktail - *sq->khead;
}
