From 10bad6b9a15f56a4eefb1a12a0ebb7f43c9d4a42 Mon Sep 17 00:00:00 2001 From: Jueji Yang Date: Thu, 6 Jul 2023 20:07:28 +0800 Subject: [PATCH] fix: io_uring sqpoll issue_time empty when kernel not yet read sq MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In io_uring sqpoll mode, when kernel side thread has not yet read the sqring before second fio_ioring_commit() called, the sq_ring.head will remain the same. The second fio_ioring_commit() will initialize the wrong io_u's issue_time. The old(in head) io_u‘s issue_time will to be initialized twice and new(in tail - 1) io_u's issue_time will not to be initialized. This problem will cause clat is weird, sometimes larger than lat. Signed-off-by: Jueji Yang --- engines/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engines/io_uring.c b/engines/io_uring.c index 5021239e14..9f8e8e6f48 100644 --- a/engines/io_uring.c +++ b/engines/io_uring.c @@ -646,7 +646,7 @@ static int fio_ioring_commit(struct thread_data *td) */ if (o->sqpoll_thread) { struct io_sq_ring *ring = &ld->sq_ring; - unsigned start = *ld->sq_ring.head; + unsigned start = *ld->sq_ring.tail - ld->queued; unsigned flags; flags = atomic_load_acquire(ring->flags);