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

Andrew Morton akpm at linux-foundation.org
Sat Aug 29 19:37:58 PDT 2026


On Mon, 03 Aug 2026 04:31:20 -0700 Breno Leitao <leitao at debian.org> 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.

Wondering if we can sneakily use fault-injection to do this.  Add a new
i_should_crash_now() and use fault-injection to make this function
"fail", by returning zero.  Or something else.




More information about the linux-riscv mailing list