All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix bug with rw sequence offset and io-size
@ 2024-04-18  9:22 Chana Zaks
  2024-04-18  9:22 ` [PATCH 1/2] Don break too early in readwrite mode Chana Zaks
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chana Zaks @ 2024-04-18  9:22 UTC (permalink / raw)
  To: Jens, Axboe, axboe, Vincent Fu; +Cc: fio, Chana Zaks

In readwrite mode, when io-size > size, we break too early and start
looping the addresses too soon.

Chana-Zaks-wdc (2):
  Don’t break too early in readwrite mode
  test: add test for readwrite issue

 backend.c                 |  5 +++++
 io_u.c                    | 11 +++++++++++
 t/jobs/t0032-43063a1c.fio | 12 ++++++++++++
 3 files changed, 28 insertions(+)
 create mode 100644 t/jobs/t0032-43063a1c.fio

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] Don break too early in readwrite mode
  2024-04-18  9:22 [PATCH 0/2] Fix bug with rw sequence offset and io-size Chana Zaks
@ 2024-04-18  9:22 ` Chana Zaks
  2024-04-18  9:22 ` [PATCH 2/2] test: add test for readwrite issue Chana Zaks
  2024-04-18 15:29 ` [PATCH 0/2] Fix bug with rw sequence offset and io-size Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Chana Zaks @ 2024-04-18  9:22 UTC (permalink / raw)
  To: Jens, Axboe, axboe, Vincent Fu; +Cc: fio, Chana-Zaks-wdc

From: Chana-Zaks-wdc <chana.zaks@wdc.com>

In readwrite mode, when io-size > size, we break too early and start
looping the addresses too soon. Instead of reset the address when
reaching size, we start looping after size/2, e.g. in a 50/50 rw. This
wrong behavior is demonstrated in the example below.

Before the fix:
size is 0x140000, io-size is 0x280000, max-address = 0xa0000 = size / 2.

./fio --debug=io --name=global --filename=/dev/mmcblk0p3 --size=1280K
--io_size=2560k --bs=128K --offset=0   --name=test1 --rw=rw| grep "complete: io_u"

io 5646 complete: io_u 0x560337a20840: off=0x60000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x80000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x20000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x40000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x60000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0xa0000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x0,	    len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x20000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x40000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x0,     len=0x20000, ddir=1, file=/dev/mmcblk0p3
Io 5646 complete: io_u 0x560337a20840: off=0x60000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x80000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x20000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x40000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0x60000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 5646 complete: io_u 0x560337a20840: off=0xa0000, len=0x20000, ddir=0, file=/dev/mmcblk0p3

After the fix max-address = 0x120000 = size – len:

io 32594 complete: io_u 0x70fc000980: off=0x0,     len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x20000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x40000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x0,     len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x60000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x80000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x20000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x40000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x60000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0xa0000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x80000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0xc0000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0xa0000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0xe0000, len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x100000,len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x120000,len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0xc0000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0xe0000, len=0x20000, ddir=1, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x0,     len=0x20000, ddir=0, file=/dev/mmcblk0p3
io 32594 complete: io_u 0x70fc000980: off=0x20000, len=0x20000, ddir=0, file=/dev/mmcblk0p3

Fixes: ac002339c382 (Fix bug with rw sequence offset and io_limit)
Signed-off-by: Chana-Zaks-wdc <chana.zaks@wdc.com>
---
 backend.c |  5 +++++
 io_u.c    | 11 +++++++++++
 2 files changed, 16 insertions(+)

diff --git a/backend.c b/backend.c
index fb7dc68a..fe03eab3 100644
--- a/backend.c
+++ b/backend.c
@@ -977,6 +977,11 @@ static void do_io(struct thread_data *td, uint64_t *bytes_done)
 	*/
 	if (td_write(td) && td_random(td) && td->o.norandommap)
 		total_bytes = max(total_bytes, (uint64_t) td->o.io_size);
+
+	/* Don't break too early if io_size > size */
+	if (td_rw(td) && !td_random(td))
+		total_bytes = max(total_bytes, (uint64_t)td->o.io_size);
+
 	/*
 	 * If verify_backlog is enabled, we'll run the verify in this
 	 * handler as well. For that case, we may need up to twice the
diff --git a/io_u.c b/io_u.c
index 09e5f15a..83895893 100644
--- a/io_u.c
+++ b/io_u.c
@@ -360,6 +360,17 @@ static int get_next_seq_offset(struct thread_data *td, struct fio_file *f,
 		loop_cache_invalidate(td, f);
 	}
 
+	/*
+	 * If we reach the end for a rw-io-size based run, reset us back to 0
+	 * and invalidate the cache, if we need to.
+	 */
+	if (td_rw(td) && o->io_size > o->size) {
+		if (f->last_pos[ddir] >= f->io_size + get_start_offset(td, f)) {
+			f->last_pos[ddir] = f->file_offset;
+			loop_cache_invalidate(td, f);
+		}
+        }
+
 	if (f->last_pos[ddir] < f->real_file_size) {
 		uint64_t pos;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] test: add test for readwrite issue
  2024-04-18  9:22 [PATCH 0/2] Fix bug with rw sequence offset and io-size Chana Zaks
  2024-04-18  9:22 ` [PATCH 1/2] Don break too early in readwrite mode Chana Zaks
@ 2024-04-18  9:22 ` Chana Zaks
  2024-04-18 15:29 ` [PATCH 0/2] Fix bug with rw sequence offset and io-size Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Chana Zaks @ 2024-04-18  9:22 UTC (permalink / raw)
  To: Jens, Axboe, axboe, Vincent Fu; +Cc: fio, Chana-Zaks-wdc

From: Chana-Zaks-wdc <chana.zaks@wdc.com>

test the previous commit: Don’t break too early in readwrite mode

In rw mode if io_size > size An early reset of the addresses occurred.
Make sure all addresses are done correctly.

Signed-off-by: Chana-Zaks-wdc <chana.zaks@wdc.com>
---
 t/jobs/t0032-43063a1c.fio | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 t/jobs/t0032-43063a1c.fio

diff --git a/t/jobs/t0032-43063a1c.fio b/t/jobs/t0032-43063a1c.fio
new file mode 100644
index 00000000..db998e5b
--- /dev/null
+++ b/t/jobs/t0032-43063a1c.fio
@@ -0,0 +1,12 @@
+# Expected results: max offset is ~1280K
+# Buggy result: max offset is ~640K
+#
+
+[global]
+ioengine=null
+size=1280K
+io_size=2560k
+bs=128K
+
+[test1]
+rw=rw
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Fix bug with rw sequence offset and io-size
  2024-04-18  9:22 [PATCH 0/2] Fix bug with rw sequence offset and io-size Chana Zaks
  2024-04-18  9:22 ` [PATCH 1/2] Don break too early in readwrite mode Chana Zaks
  2024-04-18  9:22 ` [PATCH 2/2] test: add test for readwrite issue Chana Zaks
@ 2024-04-18 15:29 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2024-04-18 15:29 UTC (permalink / raw)
  To: Vincent Fu, Chana Zaks; +Cc: fio


On Thu, 18 Apr 2024 12:22:20 +0300, Chana Zaks wrote:
> In readwrite mode, when io-size > size, we break too early and start
> looping the addresses too soon.
> 
> Chana-Zaks-wdc (2):
>   Don’t break too early in readwrite mode
>   test: add test for readwrite issue
> 
> [...]

Applied, thanks!

[1/2] Don break too early in readwrite mode
      commit: d782b76fc9086dac25d674a9439352f9fa962db1
[2/2] test: add test for readwrite issue
      commit: c6e2a258fbac28f6f421eef1a3be2e5ad5f5a01e

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-18 15:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-18  9:22 [PATCH 0/2] Fix bug with rw sequence offset and io-size Chana Zaks
2024-04-18  9:22 ` [PATCH 1/2] Don break too early in readwrite mode Chana Zaks
2024-04-18  9:22 ` [PATCH 2/2] test: add test for readwrite issue Chana Zaks
2024-04-18 15:29 ` [PATCH 0/2] Fix bug with rw sequence offset and io-size Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.