Re: [PATCH v2] tools/mm: add hwpoison-panic tool

From: David Hildenbrand (Arm)

Date: Mon Sep 07 2026 - 08:50:32 EST


On 8/30/26 04:37, Andrew Morton wrote:
> On Mon, 03 Aug 2026 04:31:20 -0700 Breno Leitao <leitao@xxxxxxxxxx> wrote:
>
>> Add a tool that enables the vm.panic_on_unrecoverable_memory_failure
>> sysctl, picks a kernel-owned PFN and writes its physical address to
>> hard_offline_page. Three page kinds are selectable with -k: rodata
>> (default), slab or pgtable. In all cases the host should panic.
>>
>> Example:
>>
>> # ./hwpoison-panic -k slab --yes-panic-my-kernel
>> injecting hwpoison at phys 0x100032000 (pfn 0x100032, kind=slab)
>> expecting kernel panic: 'Memory failure: <pfn>: unrecoverable page'
>>
>> In dmesg, you will see:
>>
>> Memory failure: 0x100032: unhandlable page.
>> Memory failure: 0x100032: recovery action for reserved kernel page: Ignored
>> Kernel panic - not syncing: Memory failure: 0x100032: unrecoverable page
>>
>> This lives in tools/mm rather than selftests/mm because every successful
>> run crashes the machine, which is not something to run from CI.
>
> I wonder if we can fix this. Add a knob which tells the kernel not to
> panic/oops/crash/etc. Instead it sends a message "i tried to crash but
> you told me not to" and proceeds.
>
> Set that knob around your hwpoison-panic tool and voila, it's now a
> selftest.

We just shot down a random "kernel-owned PFN" (marking it hwpoison etc).

That's really not something you want to do from a selftest.

You'd need some kind of hwpoison simulation mode.

--
Cheers,

David