All of lore.kernel.org
 help / color / mirror / Atom feed
From: SJ Park <sj@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: SJ Park <sj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Miaohe Lin <linmiaohe@huawei.com>,
	Naoya Horiguchi <nao.horiguchi@gmail.com>,
	Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	david@kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, linux-riscv@lists.infradead.org,
	kernel-team@meta.com
Subject: Re: [PATCH v3] tools/mm: add hwpoison-panic tool
Date: Thu, 13 Aug 2026 20:18:10 -0700	[thread overview]
Message-ID: <20260814031810.88417-1-sj@kernel.org> (raw)
In-Reply-To: <20260813-memory_failure_rewrite_test-v3-1-f9fb6542cbff@debian.org>

On Thu, 13 Aug 2026 04:45:15 -0700 Breno Leitao <leitao@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'

Too trivial nit, but I couldn't resist.  Why print '<pfn>' instead of the real
pfn value, while we know it?

> 
> 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.
> 
> The --yes-panic-my-kernel argument is required so an accidental
> invocation does not take the box down.

Looks useful to me, thank you!

> 
> Signed-off-by: Breno Leitao <leitao@debian.org>

Reviewed-by: SJ Park <sj@kernel.org>

[...]
> +static const char *inject_hwpoison(const struct page_kind *kind,
> +				   uint64_t phys_addr, uint64_t pfn)
> +{
> +	char buf[32];
> +	int fd, len;
> +	ssize_t ret;
> +
> +	printf("injecting hwpoison at phys 0x%llx (pfn 0x%llx, kind=%s)\n",
> +	       (unsigned long long)phys_addr, (unsigned long long)pfn,
> +	       kind->name);
> +	printf("expecting kernel panic: 'Memory failure: <pfn>: unrecoverable page'\n");
> +	fflush(stdout);
> +
> +	fd = open(INJECT_PATH, O_WRONLY);
> +	if (fd < 0)
> +		return "cannot open " INJECT_PATH;
> +
> +	len = snprintf(buf, sizeof(buf), "0x%llx", (unsigned long long)phys_addr);

Yet another trivial comment.  I'm not a big fan of >80 columns lines, but I
understand there are various tastes :)


Thanks,
SJ

[...]


WARNING: multiple messages have this Message-ID (diff)
From: SJ Park <sj@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: SJ Park <sj@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Miaohe Lin <linmiaohe@huawei.com>,
	Naoya Horiguchi <nao.horiguchi@gmail.com>,
	Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	david@kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, linux-riscv@lists.infradead.org,
	kernel-team@meta.com
Subject: Re: [PATCH v3] tools/mm: add hwpoison-panic tool
Date: Thu, 13 Aug 2026 20:18:10 -0700	[thread overview]
Message-ID: <20260814031810.88417-1-sj@kernel.org> (raw)
In-Reply-To: <20260813-memory_failure_rewrite_test-v3-1-f9fb6542cbff@debian.org>

On Thu, 13 Aug 2026 04:45:15 -0700 Breno Leitao <leitao@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'

Too trivial nit, but I couldn't resist.  Why print '<pfn>' instead of the real
pfn value, while we know it?

> 
> 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.
> 
> The --yes-panic-my-kernel argument is required so an accidental
> invocation does not take the box down.

Looks useful to me, thank you!

> 
> Signed-off-by: Breno Leitao <leitao@debian.org>

Reviewed-by: SJ Park <sj@kernel.org>

[...]
> +static const char *inject_hwpoison(const struct page_kind *kind,
> +				   uint64_t phys_addr, uint64_t pfn)
> +{
> +	char buf[32];
> +	int fd, len;
> +	ssize_t ret;
> +
> +	printf("injecting hwpoison at phys 0x%llx (pfn 0x%llx, kind=%s)\n",
> +	       (unsigned long long)phys_addr, (unsigned long long)pfn,
> +	       kind->name);
> +	printf("expecting kernel panic: 'Memory failure: <pfn>: unrecoverable page'\n");
> +	fflush(stdout);
> +
> +	fd = open(INJECT_PATH, O_WRONLY);
> +	if (fd < 0)
> +		return "cannot open " INJECT_PATH;
> +
> +	len = snprintf(buf, sizeof(buf), "0x%llx", (unsigned long long)phys_addr);

Yet another trivial comment.  I'm not a big fan of >80 columns lines, but I
understand there are various tastes :)


Thanks,
SJ

[...]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2026-08-14  3:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 11:45 [PATCH v3] tools/mm: add hwpoison-panic tool Breno Leitao
2026-08-13 11:45 ` Breno Leitao
2026-08-13 12:07 ` Miaohe Lin
2026-08-13 12:07   ` Miaohe Lin
2026-08-14  3:18 ` SJ Park [this message]
2026-08-14  3:18   ` SJ Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260814031810.88417-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=david@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=leitao@debian.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=nao.horiguchi@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.