Re: mm/memtest: the reserved-region array is reallocated inside the range under test

From: Mike Rapoport

Date: Wed Dec 02 2026 - 02:20:32 EST


On Mon, Nov 23, 2026 at 05:15:28PM +0000, Norman Herms wrote:
> Hi Mike,
>
> On a board whose DRAM fails one word in every 256 bytes, memtest()
> reserves every failing word on its own, 512 reservations over 1.6 MiB.
> Past the 128 static entries, memblock_double_array() allocates the new
> reserved array from free memory inside the range memtest() is still
> reading back, and the array's own entries then fail the compare:
> another 42 KiB at the top of RAM (0x1bf3c2000-0x1bf3cc800 here, inside
> the tested range 0x60100000-0x1bf3cd040) is reserved as bad, in runs
> of 16 bytes every 24 bytes, the size of struct memblock_region.
>
> With memtest=4 the next pattern is written over the live array, and
> the board resets during that pattern; we have not separated that from
> a 16 s boot watchdog.
>
> Coalescing nearby bad words, or reserving only after a range's verify
> pass, would avoid it.

Unfortunately neither of those solve the general case :(

Coalescing only reduces the chance that a reservation will fall onto a bad
region.

Reserving after a pass means that we need to keep the intermediate state
somewhere. If it's static array we may run out of space, if we allocate it
we're back to potentially hitting a bad range.

> Seen on 6.18.54 (arm64, Allwinner A733, 6 GiB); mm/memtest.c is unchanged
> in linux-next.
>
> Measured on my board by AI agents, analysis with an AI assistant;
> a report, not a Tested-by.
>
> Norman
>

--
Sincerely yours,
Mike.