Merge patch series "memtest performance improvements"
Rasmus Villemoes <ravi@prevas.dk> says: The first two patches make memtest run ~40x faster (when, as it should be, dcache is disabled), with the second patch being responsible for most of that. At least on the beagleboneblack which I used for testing; other boards and configurations will likely see different numbers. This is for CONFIG_SYS_ALT_MEMTEST=y and CONFIG_SYS_ALT_MEMTEST_BITFLIP=n; one could probably get a similar improvement in the bitflip case since that also has a schedule() call in the inner loop. Link: https://lore.kernel.org/r/20250822181848.3325832-1-ravi@prevas.dk
This commit is contained in:
40
cmd/mem.c
40
cmd/mem.c
@@ -712,19 +712,16 @@ static int do_mem_loopw(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
#endif /* CONFIG_LOOPW */
|
||||
|
||||
#ifdef CONFIG_CMD_MEMTEST
|
||||
static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||
vu_long *dummy)
|
||||
static ulong mem_test_alt(volatile ulong *buf, ulong start_addr, ulong end_addr,
|
||||
volatile ulong *dummy)
|
||||
{
|
||||
vu_long *addr;
|
||||
volatile ulong *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 */
|
||||
@@ -735,8 +732,10 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||
0x00000055, /* four non-adjacent bits */
|
||||
0xaaaaaaaa, /* alternating 1/0 */
|
||||
};
|
||||
/* Rate-limit schedule() calls to one for every 256 words. */
|
||||
u8 count = 0;
|
||||
|
||||
num_words = (end_addr - start_addr) / sizeof(vu_long);
|
||||
num_words = (end_addr - start_addr) / sizeof(ulong);
|
||||
|
||||
/*
|
||||
* Data line test: write a pattern to the first
|
||||
@@ -818,8 +817,8 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||
*
|
||||
* Returns: 0 if the test succeeds, 1 if the test fails.
|
||||
*/
|
||||
pattern = (vu_long)0xaaaaaaaaaaaaaaaa;
|
||||
anti_pattern = (vu_long)0x5555555555555555;
|
||||
pattern = (ulong)0xaaaaaaaaaaaaaaaa;
|
||||
anti_pattern = (ulong)0x5555555555555555;
|
||||
|
||||
debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words);
|
||||
/*
|
||||
@@ -840,7 +839,7 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||
if (temp != pattern) {
|
||||
printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:"
|
||||
" expected 0x%.8lx, actual 0x%.8lx\n",
|
||||
start_addr + offset*sizeof(vu_long),
|
||||
start_addr + offset*sizeof(ulong),
|
||||
pattern, temp);
|
||||
errs++;
|
||||
if (ctrlc())
|
||||
@@ -862,7 +861,7 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||
printf("\nFAILURE: Address bit stuck low or"
|
||||
" shorted @ 0x%.8lx: expected 0x%.8lx,"
|
||||
" actual 0x%.8lx\n",
|
||||
start_addr + offset*sizeof(vu_long),
|
||||
start_addr + offset*sizeof(ulong),
|
||||
pattern, temp);
|
||||
errs++;
|
||||
if (ctrlc())
|
||||
@@ -890,7 +889,8 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||
* Fill memory with a known pattern.
|
||||
*/
|
||||
for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
|
||||
schedule();
|
||||
if (!count++)
|
||||
schedule();
|
||||
addr[offset] = pattern;
|
||||
}
|
||||
|
||||
@@ -898,12 +898,13 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||
* Check each location and invert it for the second pass.
|
||||
*/
|
||||
for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
|
||||
schedule();
|
||||
if (!count++)
|
||||
schedule();
|
||||
temp = addr[offset];
|
||||
if (temp != pattern) {
|
||||
printf("\nFAILURE (read/write) @ 0x%.8lx:"
|
||||
" expected 0x%.8lx, actual 0x%.8lx)\n",
|
||||
start_addr + offset*sizeof(vu_long),
|
||||
start_addr + offset*sizeof(ulong),
|
||||
pattern, temp);
|
||||
errs++;
|
||||
if (ctrlc())
|
||||
@@ -918,13 +919,14 @@ static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr,
|
||||
* Check each location for the inverted pattern and zero it.
|
||||
*/
|
||||
for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
|
||||
schedule();
|
||||
if (!count++)
|
||||
schedule();
|
||||
anti_pattern = ~pattern;
|
||||
temp = addr[offset];
|
||||
if (temp != anti_pattern) {
|
||||
printf("\nFAILURE (read/write): @ 0x%.8lx:"
|
||||
" expected 0x%.8lx, actual 0x%.8lx)\n",
|
||||
start_addr + offset*sizeof(vu_long),
|
||||
start_addr + offset*sizeof(ulong),
|
||||
anti_pattern, temp);
|
||||
errs++;
|
||||
if (ctrlc())
|
||||
|
||||
Reference in New Issue
Block a user