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>
This commit is contained in:
Rasmus Villemoes
2025-09-02 14:11:36 -06:00
committed by Tom Rini
parent 185aa00a4f
commit 86c5c25b6c
+3 -6
View File
@@ -719,12 +719,9 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
ulong errs = 0;
ulong val, readback;
int j;
vu_long offset;
vu_long test_offset;
vu_long pattern;
vu_long temp;
vu_long anti_pattern;
vu_long num_words;
ulong offset, test_offset;
ulong pattern, anti_pattern;
ulong temp, num_words;
static const ulong bitpattern[] = {
0x00000001, /* single bit */
0x00000003, /* two adjacent bits */