memtest: don't volatile-qualify local variables
authorRasmus Villemoes <ravi@prevas.dk>
Fri, 22 Aug 2025 18:18:46 +0000 (20:18 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 2 Sep 2025 20:11:36 +0000 (14:11 -0600)
commit86c5c25b6ca99025ac8ebcbe5c53ea0f398d1f44
tree05485ec20890e6f1cccadcc32283bbd83cf7a6f3
parent185aa00a4f5d6fee2c023d8fc459db45b91846d0
memtest: don't volatile-qualify local variables

It is obviously important that the addr pointer used to access the
memory region being tested is volatile-qualified, to prevent the
compiler from optimizing out the "write this value, read it back,
check that it is what we expect".

However, none of these auxiliary variables have any such need for,
effectively, being forced to live on the stack and cause each and
every reference to them to do a memory access.

This makes the memtest about 15% faster on a beagleboneblack.

Before:

  => dcache off
  => time mtest 0x81000000 0x81100000 0 1
  Testing 81000000 ... 81100000:
  Iteration:      1
  Tested 1 iteration(s) with 0 errors.

  time: 10.868 seconds

After:

  => dcache off
  => time mtest 0x81000000 0x81100000 0 1
  Testing 81000000 ... 81100000:
  Iteration:      1
  Tested 1 iteration(s) with 0 errors.

  time: 9.209 seconds

[Without the 'dcache off', there's no difference in the time, about
0.6s, but the memtest cannot usefully be done with dcache enabled.]

Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
Tested-by: Anshul Dalal <anshuld@ti.com>
cmd/mem.c