Skip to contentSkip to conversation

fix clat reporting with sqthread poll

PATCH Applied Ankit Kumar 2 participants 4 messages Nov 23, 2022 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20221123113911epcas5p198248dd58155d554974c3221d843271d@epcas5p1.samsung.com

#1 lore raw

v2 cover fix clat reporting with sqthread poll

When sqthread_poll is specified for io_uring and io_uring_cmd I/O engines, fio reports garbage value for completion latencies. This is because the issue time was not recorded. This adds a change for that. As the submission latency for sqthread poll is really just the time it takes to fill in the SQ ring entries and any syscall required to wake up the idle kernel thread. So there is really no need to report those.

Also Updated the documentation to reflect the changes.

FIO command used to test:
fio --name=test --size=1M --rw=randread --ioengine=io_uring --sqthread_poll=1

Latencies reported before the change:

    clat (msec): min=7543.5k, max=7543.5k, avg=7543493.06, stdev= 8.30
     lat (usec): min=104, max=5070, avg=131.54, stdev=309.92
    clat percentiles (msec):
     |  1.00th=[17113],  5.00th=[17113], 10.00th=[17113], 20.00th=[17113],
     | 30.00th=[17113], 40.00th=[17113], 50.00th=[17113], 60.00th=[17113],
     | 70.00th=[17113], 80.00th=[17113], 90.00th=[17113], 95.00th=[17113],
     | 99.00th=[17113], 99.50th=[17113], 99.90th=[17113], 99.95th=[17113],
     | 99.99th=[17113]

lat (msec) : >=2000=100.00%

latency reported after the changes:

    clat (usec): min=106, max=5122, avg=132.95, stdev=313.07
     lat (usec): min=106, max=5125, avg=133.11, stdev=313.27
    clat percentiles (usec):
     |  1.00th=[  108],  5.00th=[  108], 10.00th=[  109], 20.00th=[  111],
     | 30.00th=[  112], 40.00th=[  113], 50.00th=[  114], 60.00th=[  115],
     | 70.00th=[  116], 80.00th=[  118], 90.00th=[  120], 95.00th=[  121],
     | 99.00th=[  122], 99.50th=[  122], 99.90th=[ 5145], 99.95th=[ 5145],
     | 99.99th=[ 5145]

lat (usec) : 250=99.61%
lat (msec) : 10=0.39%

This fixes the issue: https://github.com/axboe/fio/issues/1484

Ankit Kumar (2):
engines:io_uring: fix clat calculation for sqthread poll
doc: update about sqthread_poll

 HOWTO.rst          |  4 +++-
 engines/io_uring.c | 20 ++++++++++++++++++++
 fio.1              |  4 +++-
 3 files changed, 26 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
#2 lore raw

PATCH v2 1/2 engines:io_uring: fix clat calculation for sqthread poll

When sqthread_poll is specified for io_uring and io_uring_cmd I/O engines, fio reports garbage value for completion latencies. This is because the issue time was not recorded. Added a change for that. On the other hand submission latency for sqthread poll is really just the time it takes to fill in the SQ ring entries and any syscall required to wake up the idle kernel thread. So there is really no need to report those.

This fixes the issue: https://github.com/axboe/fio/issues/1484

---
 engines/io_uring.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
engines/io_uring.c +20 -0
index 3c656b77..a9abd11d 100644
@@ -637,12 +637,16 @@ 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 flags;
 
 		flags = atomic_load_acquire(ring->flags);
 		if (flags & IORING_SQ_NEED_WAKEUP)
 			io_uring_enter(ld, ld->queued, 0,
 					IORING_ENTER_SQ_WAKEUP);
+		fio_ioring_queued(td, start, ld->queued);
+		io_u_mark_submit(td, ld->queued);
+
 		ld->queued = 0;
 		return 0;
 	}
@@ -804,6 +808,14 @@ static int fio_ioring_queue_init(struct thread_data *td)
 			p.flags |= IORING_SETUP_SQ_AFF;
 			p.sq_thread_cpu = o->sqpoll_cpu;
 		}
+
+		/*
+		 * Submission latency for sqpoll_thread is just the time it
+		 * takes to fill in the SQ ring entries, and any syscall if
+		 * IORING_SQ_NEED_WAKEUP is set, we don't need to log that time
+		 * separately.
+		 */
+		td->o.disable_slat = 1;
 	}
 
 	/*
@@ -876,6 +888,14 @@ static int fio_ioring_cmd_queue_init(struct thread_data *td)
 			p.flags |= IORING_SETUP_SQ_AFF;
 			p.sq_thread_cpu = o->sqpoll_cpu;
 		}
+
+		/*
+		 * Submission latency for sqpoll_thread is just the time it
+		 * takes to fill in the SQ ring entries, and any syscall if
+		 * IORING_SQ_NEED_WAKEUP is set, we don't need to log that time
+		 * separately.
+		 */
+		td->o.disable_slat = 1;
 	}
 	if (o->cmd_type == FIO_URING_CMD_NVME) {
 		p.flags |= IORING_SETUP_SQE128;
Signature · 1 line
2.17.1
#3 lore raw

PATCH v2 2/2 doc: update about sqthread_poll

In reply to Ankit Kumar

Update that when sqthread_poll is enabled fio will not report submission latency.

---
 HOWTO.rst | 4 +++-
 fio.1     | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
HOWTO.rst +3 -1
index e796f961..5f8a8466 100644
@@ -2299,7 +2299,9 @@ with the caveat that when used on the command line, they must come after the
 	kernel of available items in the SQ ring. If this option is set, the
 	act of submitting IO will be done by a polling thread in the kernel.
 	This frees up cycles for fio, at the cost of using more CPU in the
-	system.
+	system. As submission is just the time it takes to fill in the sqe
+	entries and any syscall required to wake up the idle kernel thread,
+	fio will not report submission latencies.
 
 .. option:: sqthread_poll_cpu=int : [io_uring] [io_uring_cmd]
 
fio.1 +3 -1
index 9e33c9e1..a156bf5d 100644
@@ -2090,7 +2090,9 @@ sqthread_poll option.
 Normally fio will submit IO by issuing a system call to notify the kernel of
 available items in the SQ ring. If this option is set, the act of submitting IO
 will be done by a polling thread in the kernel. This frees up cycles for fio, at
-the cost of using more CPU in the system.
+the cost of using more CPU in the system. As submission is just the time it
+takes to fill in the sqe entries and any syscall required to wake up the idle
+kernel thread, fio will not report submission latencies.
 .TP
 .BI (io_uring,io_uring_cmd)sqthread_poll_cpu \fR=\fPint
 When `sqthread_poll` is set, this option provides a way to define which CPU
Signature · 1 line
2.17.1
Applied
#4 lore raw
In reply to Ankit Kumar
Quoted 38 lines · Ankit Kumar

When sqthread_poll is specified for io_uring and io_uring_cmd I/O engines, fio reports garbage value for completion latencies. This is because the issue time was not recorded. This adds a change for that. As the submission latency for sqthread poll is really just the time it takes to fill in the SQ ring entries and any syscall required to wake up the idle kernel thread. So there is really no need to report those.

Also Updated the documentation to reflect the changes.

FIO command used to test:
fio --name=test --size=1M --rw=randread --ioengine=io_uring --sqthread_poll=1

Latencies reported before the change:

     clat (msec): min=7543.5k, max=7543.5k, avg=7543493.06, stdev= 8.30
      lat (usec): min=104, max=5070, avg=131.54, stdev=309.92
     clat percentiles (msec):
      |  1.00th=[17113],  5.00th=[17113], 10.00th=[17113], 20.00th=[17113],
      | 30.00th=[17113], 40.00th=[17113], 50.00th=[17113], 60.00th=[17113],
      | 70.00th=[17113], 80.00th=[17113], 90.00th=[17113], 95.00th=[17113],
      | 99.00th=[17113], 99.50th=[17113], 99.90th=[17113], 99.95th=[17113],
      | 99.99th=[17113]

lat (msec) : >=2000=100.00%

latency reported after the changes:

     clat (usec): min=106, max=5122, avg=132.95, stdev=313.07
      lat (usec): min=106, max=5125, avg=133.11, stdev=313.27
     clat percentiles (usec):
      |  1.00th=[  108],  5.00th=[  108], 10.00th=[  109], 20.00th=[  111],
      | 30.00th=[  112], 40.00th=[  113], 50.00th=[  114], 60.00th=[  115],
      | 70.00th=[  116], 80.00th=[  118], 90.00th=[  120], 95.00th=[  121],
      | 99.00th=[  122], 99.50th=[  122], 99.90th=[ 5145], 99.95th=[ 5145],
      | 99.99th=[ 5145]

lat (usec) : 250=99.61%
lat (msec) : 10=0.39%

This fixes the issue: https://github.com/axboe/fio/issues/1484

Quoted 9 lines

Ankit Kumar (2):
engines:io_uring: fix clat calculation for sqthread poll
doc: update about sqthread_poll

  HOWTO.rst          |  4 +++-
  engines/io_uring.c | 20 ++++++++++++++++++++
  fio.1              |  4 +++-
  3 files changed, 26 insertions(+), 2 deletions(-)

Applied. Thanks.