From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Michael Nazzareno Trimarchi <michael@amarulasolutions.com>
Cc: Tom Rini <trini@konsulko.com>,
Christian Marangi <ansuelsmth@gmail.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
u-boot@lists.denx.de, Steam Lin <stlin2@winbond.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH] cmd: mtd: Enable speed benchmarking
Date: Mon, 04 Aug 2025 11:15:44 +0200 [thread overview]
Message-ID: <87wm7jjvlr.fsf@bootlin.com> (raw)
In-Reply-To: <CAOf5uwnju+Z4bY0Cx0fy05TOLtaQqikq3z51zqDf2nDgCzQyWw@mail.gmail.com> (Michael Nazzareno Trimarchi's message of "Thu, 3 Jul 2025 19:19:45 +0200")
Hello Michael,
>> MA35D1> mtd read nor0 0x81000000 0 0x10000
>> Reading 65536 byte(s) at offset 0x00000000
>> MA35D1> mtd read.benchmark nor0 0x81000000 0 0x10000
>> Reading 65536 byte(s) at offset 0x00000000
>> Read speed: 3752kiB/s
>>
>
> I was using time and reading but this looked much nicer. I will give it a try
> and review.
Thanks! It turned out very useful for development purposes :-)
>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
>> ---
[...]
>> - bool dump, read, raw, woob, write_empty_pages, has_pages = false;
>> + bool dump, read, raw, woob, benchmark, write_empty_pages, has_pages = false;
>> u64 start_off, off, len, remaining, default_len;
>> struct mtd_oob_ops io_op = {};
>> uint user_addr = 0, npages;
>> + u32 bench_start, bench_end;
>
> unsigned long
Okay.
>> const char *cmd = argv[0];
>> struct mtd_info *mtd;
>> u32 oob_len;
>> @@ -490,6 +492,7 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
>> read = dump || !strncmp(cmd, "read", 4);
>> raw = strstr(cmd, ".raw");
>> woob = strstr(cmd, ".oob");
>> + benchmark = strstr(cmd, ".benchmark");
>> write_empty_pages = !has_pages || strstr(cmd, ".dontskipff");
>>
>> argc -= 2;
>> @@ -559,6 +562,9 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
>>
>> led_activity_blink();
>>
>> + if (benchmark)
>> + bench_start = timer_get_us();
>> +
>> /* Loop over the pages to do the actual read/write */
>> while (remaining) {
>> /* Skip the block if it is bad */
>> @@ -586,6 +592,13 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
>> io_op.oobbuf += io_op.oobretlen;
>> }
>>
>> + if (benchmark && bench_start) {
>> + bench_end = timer_get_us();
>> + printf("%s speed: %lukiB/s\n",
>> + read ? "Read" : "Write",
>> + ((io_op.len * 1000000) / (bench_end - bench_start)) / 1024);
>
> Did you check if it can not wrap?
That is a good question, if my calculations are correct, time capture
may wrap if one spends more than 1h12 in the Bootloader. So yes it is
'doable' to make the time overlap.
But is this relevant? It really is a development feature at the moment
(developers comparing speeds would notice the overlap) and Bootloaders
in general are not supposed to run for that long anyway. So I would
argue that it is acceptable like that.
Thanks,
Miquèl
next prev parent reply other threads:[~2025-08-04 13:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-03 16:58 [PATCH] cmd: mtd: Enable speed benchmarking Miquel Raynal
2025-07-03 17:19 ` Michael Nazzareno Trimarchi
2025-08-04 9:15 ` Miquel Raynal [this message]
2025-08-29 8:27 ` Michael Nazzareno Trimarchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wm7jjvlr.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=ansuelsmth@gmail.com \
--cc=michael@amarulasolutions.com \
--cc=stlin2@winbond.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.