All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cmd: mtd: fix speed measurement in the speed benchmark
@ 2025-08-25 23:48 Mikhail Kshevetskiy
  2025-08-26 14:23 ` Miquel Raynal
  0 siblings, 1 reply; 18+ messages in thread
From: Mikhail Kshevetskiy @ 2025-08-25 23:48 UTC (permalink / raw)
  To: Tom Rini, Michael Trimarchi, Miquel Raynal, Heinrich Schuchardt,
	Christian Marangi, u-boot
  Cc: Mikhail Kshevetskiy

The shown speed inverse linearly depends on size of data.
See the output:

  spi-nand: spi_nand nand@0: Micron SPI NAND was found.
  spi-nand: spi_nand nand@0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
  ...
  => mtd read.benchmark spi-nand0 $loadaddr 0 0x40000
  Reading 262144 byte(s) (128 page(s)) at offset 0x00000000
  Read speed: 63kiB/s
  => mtd read.benchmark spi-nand0 $loadaddr 0 0x20000
  Reading 131072 byte(s) (64 page(s)) at offset 0x00000000
  Read speed: 127kiB/s
  => mtd read.benchmark spi-nand0 $loadaddr 0 0x10000
  Reading 65536 byte(s) (32 page(s)) at offset 0x00000000
  Read speed: 254kiB/s

In the spi-nand case 'io_op.len' is not the same as 'len',
thus we divide a size of the single block on total time.
This is wrong, we should divide on the time for a single
block.

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
---
 cmd/mtd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cmd/mtd.c b/cmd/mtd.c
index 2520b89eed2..deac7d1f002 100644
--- a/cmd/mtd.c
+++ b/cmd/mtd.c
@@ -469,7 +469,7 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
 {
 	bool dump, read, raw, woob, benchmark, write_empty_pages, has_pages = false;
 	u64 start_off, off, len, remaining, default_len;
-	unsigned long bench_start, bench_end;
+	unsigned long bench_start, bench_end, block_time;
 	struct mtd_oob_ops io_op = {};
 	uint user_addr = 0, npages;
 	const char *cmd = argv[0];
@@ -594,9 +594,10 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
 
 	if (benchmark && bench_start) {
 		bench_end = timer_get_us();
+		block_time = (bench_end - bench_start) / (len / io_op.len);
 		printf("%s speed: %lukiB/s\n",
 		       read ? "Read" : "Write",
-		       ((io_op.len * 1000000) / (bench_end - bench_start)) / 1024);
+		       ((io_op.len * 1000000) / block_time) / 1024);
 	}
 
 	led_activity_off();
-- 
2.50.1


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

end of thread, other threads:[~2025-08-29 22:39 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-25 23:48 [PATCH] cmd: mtd: fix speed measurement in the speed benchmark Mikhail Kshevetskiy
2025-08-26 14:23 ` Miquel Raynal
2025-08-26 14:32   ` Michael Nazzareno Trimarchi
2025-08-26 14:35     ` Mikhail Kshevetskiy
2025-08-26 14:33   ` Mikhail Kshevetskiy
2025-08-26 14:59     ` Miquel Raynal
2025-08-26 19:21       ` [PATCH v2] " Mikhail Kshevetskiy
2025-08-28  9:45         ` Miquel Raynal
2025-08-29  7:48           ` [PATCH v3 0/2] cmd: mtd: fix benchmarking Mikhail Kshevetskiy
2025-08-29  7:48             ` [PATCH v3 1/2] cmd: mtd: fix speed measurement in the speed benchmark Mikhail Kshevetskiy
2025-08-29  7:48             ` [PATCH v3 2/2] cmd: mtd: add benchmark option to the help Mikhail Kshevetskiy
2025-08-29  7:55           ` [PATCH v4 0/2] cmd: mtd: fix benchmarking Mikhail Kshevetskiy
2025-08-29  7:55             ` [PATCH v4 1/2] Prepare v2025.10-rc3 Mikhail Kshevetskiy
2025-08-29  7:55             ` [PATCH v4 2/2] cmd: mtd: fix speed measurement in the speed benchmark Mikhail Kshevetskiy
2025-08-29  7:59           ` [PATCH v5 0/2] cmd: mtd: fix benchmarking Mikhail Kshevetskiy
2025-08-29  7:59             ` [PATCH v5 1/2] cmd: mtd: fix speed measurement in the speed benchmark Mikhail Kshevetskiy
2025-08-29  7:59             ` [PATCH v5 2/2] cmd: mtd: add benchmark option to the help Mikhail Kshevetskiy
2025-08-29 21:54               ` Miquel Raynal

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.