Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Lance Yang <lance.yang@linux.dev>
Cc: david@kernel.org, linmiaohe@huawei.com, nao.horiguchi@gmail.com,
	 akpm@linux-foundation.org, corbet@lwn.net,
	skhan@linuxfoundation.org, ljs@kernel.org,
	 Liam.Howlett@oracle.com, vbabka@kernel.org, rppt@kernel.org,
	surenb@google.com,  mhocko@suse.com, shuah@kernel.org,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
	 kernel-team@meta.com
Subject: Re: [PATCH v5 2/4] mm/memory-failure: add panic option for unrecoverable pages
Date: Mon, 11 May 2026 07:44:37 -0700	[thread overview]
Message-ID: <agHp-wFHe3FjWAAV@gmail.com> (raw)
In-Reply-To: <20260510144220.92522-1-lance.yang@linux.dev>

On Sun, May 10, 2026 at 10:42:20PM +0800, Lance Yang wrote:
> 
> On Wed, May 06, 2026 at 09:18:12AM -0700, Breno Leitao wrote:
> >On Tue, Apr 28, 2026 at 11:07:21AM +0800, Lance Yang wrote:
> >> 
> >> On Mon, Apr 27, 2026 at 05:49:28PM +0200, David Hildenbrand (Arm) wrote:
> >> >> +	switch (type) {
> >> >> +	case MF_MSG_KERNEL:
> >> >> +	case MF_MSG_UNKNOWN:
> >> >> +		return true;
> >> >> +	case MF_MSG_KERNEL_HIGH_ORDER:
> >> >> +		/*
> >> >> +		 * Rule out a concurrent buddy allocation: give the
> >> >> +		 * allocator a moment to finish prep_new_page() and
> >> >> +		 * re-check. A genuine high-order kernel tail page stays
> >> >> +		 * unowned; an in-flight allocation will have bumped the
> >> >> +		 * refcount, attached a mapping, or placed the page on
> >> >> +		 * an LRU by now.
> >> >> +		 */
> >> >> +		p = pfn_to_online_page(pfn);
> >> >> +		if (!p)
> >> >> +			return true;
> >> >> +		/*
> >> >> +		 * Yield so a concurrent allocator on another CPU can
> >> >> +		 * finish prep_new_page() and have its writes become
> >> >> +		 * visible before we resample the page state.
> >> >> +		 */
> >> >> +		cpu_relax();
> >> >> +		return page_count(p) == 0 &&
> >> >> +		       !PageLRU(p) &&
> >> >> +		       !page_mapped(p) &&
> >> >> +		       !page_folio(p)->mapping &&
> >> >> +		       !is_free_buddy_page(p);
> >> >
> >> >I don't get what you are doing here. The right way to check for a tail page is
> >> >not by checking the refcount.
> >> >
> >> >Further, you are not holding a folio reference? If so, calling
> >> >page_mapped/folio_mapped is shaky. On concurrent folio split you can trigger a
> >> >VM_WARN_ON_FOLIO().
> >> >
> >> >
> >> >Maybe folio_snapshot() is what you are looking for, if you are in fact not
> >> >holding a reference?
> >> 
> >> Right! Maybe we should not try to make this decision in
> >> panic_on_unrecoverable_mf().
> >> 
> >> By the time we get here, we only know the final MF_MSG_* type. The
> >> real reason why get_hwpoison_page() failed is already lost.
> >> 
> >> Wonder if it would be better to split that earlier, around
> >> __get_unpoison_page()/get_any_page(). That code still knows why
> >> grabbing the page failed, either an unsupported kernel page or
> >> just a temporary race we cannot really trust :)
> >> 
> >> Then the later panic logic can be simple: panic for the stable
> >> unsupported kernel page case, and not for the temporary race case.
> >> 
> >> That would also avoid trying to guess MF_MSG_KERNEL_HIGH_ORDER here:)
> >
> >This is a very good feedback, and definitely what I wanted to do, but,
> >failed. Once we have the reason, we don't need this dance to guess the
> >reason.
> >
> >I've hacked a patch based on this approach. How does it sound?
> 
> Yes. This direction makes sense to me, not an expert though :D
> 
> I played with something similar (untested) on top of patch #01:

Thanks!

I'll prepare a new series addressing all the feedback from both
reviewers and AI analysis. I will resend soon and we can catch up
on the next revision,

Thanks for the review,
--breno


  reply	other threads:[~2026-05-11 14:45 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24 12:23 [PATCH v5 0/4] mm/memory-failure: add panic option for unrecoverable pages Breno Leitao
2026-04-24 12:23 ` [PATCH v5 1/4] mm/memory-failure: report MF_MSG_KERNEL for reserved pages Breno Leitao
2026-04-27 12:33   ` Lance Yang
2026-04-27 14:45     ` Breno Leitao
2026-04-27 15:14       ` Lance Yang
2026-04-27 15:57     ` Lance Yang
2026-04-24 12:24 ` [PATCH v5 2/4] mm/memory-failure: add panic option for unrecoverable pages Breno Leitao
2026-04-27 15:49   ` David Hildenbrand (Arm)
2026-04-28  3:07     ` Lance Yang
2026-05-06 16:18       ` Breno Leitao
2026-05-10 14:42         ` Lance Yang
2026-05-11 14:44           ` Breno Leitao [this message]
2026-04-24 12:24 ` [PATCH v5 3/4] Documentation: document panic_on_unrecoverable_memory_failure sysctl Breno Leitao
2026-04-24 12:48   ` Andrew Morton
2026-05-06 15:38     ` Breno Leitao
2026-04-24 12:24 ` [PATCH v5 4/4] selftests/mm: regression test for panic_on_unrecoverable_memory_failure Breno Leitao
2026-04-28  2:22   ` Miaohe Lin
2026-04-24 13:19 ` [PATCH v5 0/4] mm/memory-failure: add panic option for unrecoverable pages Matthew Wilcox
2026-04-24 14:39   ` Breno Leitao
2026-04-24 13:28 ` Andrew Morton

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=agHp-wFHe3FjWAAV@gmail.com \
    --to=leitao@debian.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=david@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=lance.yang@linux.dev \
    --cc=linmiaohe@huawei.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=nao.horiguchi@gmail.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=surenb@google.com \
    --cc=vbabka@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