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

From: Andrew Morton

Date: Sat Aug 29 2026 - 22:38:08 EST


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.

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.