The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: SJ Park <sj@kernel.org>
Cc: 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] tools/mm: add hwpoison-panic tool
Date: Mon, 3 Aug 2026 04:06:28 -0700	[thread overview]
Message-ID: <anB0-xHoQpQzp_dK@gmail.com> (raw)
In-Reply-To: <20260801005822.85110-1-sj@kernel.org>

On Fri, Jul 31, 2026 at 05:58:22PM -0700, SJ Park wrote:
> > This lives in tools/mm rather than selftests/mm because every successful
> > run crashes the machine, which is not something to run from CI.
> 
> If the purpose of the new program is testing, would it make more sense to put
> it under tools/testing/ ?

Sorry, this was discussed here:

https://lore.kernel.org/all/f83d5b26-b369-489b-a305-1eb5ec6fccfb@kernel.org/

> Also, does this test really need to be end-to-end test that cause panic?  How
> about doing unit test of core functions, using tools like kunit?  Or,
> live-patching panic() to only print messages and return before running the
> test?

What I want covered is the wiring, not the individual functions:
get_any_page() classifying a kernel-owned page as -ENOTRECOVERABLE,
action_result() reaching panic_on_unrecoverable_mf(), and the box
actually going down. 

Under kunit I would have to fabricate the page and stub panic(), so the
parts that break would be the parts replaced by the harness.

Unit tests for the classification helpers would be worth having on their
own. They would not replace this one.
> >  BUILD_TARGETS=page-types slabinfo page_owner_sort page_owner_filter thp_swap_allocator_test
> > +BUILD_TARGETS+=memory-failure/hwpoison-panic
> 
> I was initially thought why not underscore but dash on the name?  But, I
> realize it is obviously too persoanl taste.

Dash matches page-types.c in the same directory, I am happy using
userscore if that is the rigth approach.
> >
> > diff --git a/tools/mm/memory-failure/hwpoison-panic.c b/tools/mm/memory-failure/hwpoison-panic.c
> > new file mode 100644
> > index 0000000000000..b8076d86da15b
> > --- /dev/null
> > +++ b/tools/mm/memory-failure/hwpoison-panic.c
> > @@ -0,0 +1,353 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * hwpoison-panic: verify vm.panic_on_unrecoverable_memory_failure by
> > + * injecting a hwpoison error on a kernel-owned page and confirming the
> > + * kernel panics.
> 
> While reading the above explanation, I was expecting this program will directly
> say me if the kernel panic-ed or not.  But this only says if it was not
> panic-ed iiuc?  How about saying, like, "Trigger intentional kernel panic by
> ..." ?

You read it correctly, the program can only ever report the absence of
a panic. I will reword the header along your suggestion for v2.

> > +	kind = parse_args(argc, argv, &force);
> > +	page_size = getpagesize();
> > +	check_prereqs(force);
> 
> Maybe check_prereqs() can be called before getpagesize()?

Yes, nothing in check_prereqs() needs page_size. Moving it up in v2.

Thanks for the review,
--breno


      reply	other threads:[~2026-08-03 11:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 13:16 [PATCH] tools/mm: add hwpoison-panic tool Breno Leitao
2026-08-01  0:58 ` SJ Park
2026-08-03 11:06   ` Breno Leitao [this message]

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=anB0-xHoQpQzp_dK@gmail.com \
    --to=leitao@debian.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=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 \
    --cc=sj@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox