mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Jiaqi Yan <jiaqiyan@google.com>, linmiaohe@huawei.com, vbabka@kernel.org
Cc: osalvador@kernel.org, ljs@kernel.org, ziy@nvidia.com,
	harry.yoo@oracle.com, willy@infradead.org, osalvador@suse.de,
	jackmanb@google.com, hannes@cmpxchg.org, nao.horiguchi@gmail.com,
	william.roche@oracle.com, tony.luck@intel.com,
	wangkefeng.wang@huawei.com, jane.chu@oracle.com,
	akpm@linux-foundation.org, muchun.song@linux.dev,
	liam@infradead.org, rientjes@google.com, duenwen@google.com,
	jthoughton@google.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, vbabka@suse.cz, rppt@kernel.org,
	shuah@kernel.org, surenb@google.com, mhocko@suse.com,
	boudewijn@delta-utec.com
Subject: Re: [PATCH v7 2/3] mm/page_alloc: only free healthy pages in high-order folio
Date: Wed, 2 Dec 2026 17:53:54 +0100	[thread overview]
Message-ID: <b6e83318-7964-45a5-8fca-5ff9c755d5a3@kernel.org> (raw)
In-Reply-To: <20261110053331.2708996-3-jiaqiyan@google.com>

On 11/10/26 06:33, Jiaqi Yan wrote:
> At the end of dissolve_free_hugetlb_folio(), a free HugeTLB folio
> becomes non-HugeTLB, and it is released to buddy allocator as a
> high-order folio, e.g. a folio that contains 262144 pages if the
> folio was a 1G HugeTLB hugepage.
> 
> This is problematic if the HugeTLB hugepage contained HWPoison
> subpages. In that case, since buddy allocator does not check
> HWPoison for non-zero-order folio, the raw HWPoison page can be
> given out with its buddy page and be re-used by either kernel or
> userspace.
> 
> Memory failure recovery (MFR) in kernel does attempt to take raw
> HWPoison page off buddy allocator after
> dissolve_free_hugetlb_folio(). However, there is always a time
> window between dissolve_free_hugetlb_folio() frees a HWPoison
> high-order folio to buddy allocator and MFR takes HWPoison raw page
> off buddy allocator. Worse, a free HWPoison HugeTLB folio can also
> be dissolved outside of MFR, e.g. when shrinking the HugeTLB pool,
> and then nobody takes its HWPoison pages off buddy allocator.
> 
> Another similar situation is when a transparent huge page (THP)
> runs into memory failure but splitting failed. Such THP will
> eventually be released to buddy allocator when owning userspace
> processes are gone, but with certain subpages having HWPoison.
> 
> One obvious way to avoid these problems is to always check
> PageHWPoison() when allocating pages, which check_new_pages() only
> does if page sanity checks are enabled. However, it is against the
> past efforts to reduce sanity check overhead [1,2,3].
> 
> Instead, keep HWPoison pages out of buddy allocator when freeing a
> high-order folio. __free_pages_prepare() already walks through all
> tail pages of a high-order folio to check and clear their flags, so
> counting PageHWPoison() pages in that loop is cheap, as pointed out
> by David Hildenbrand [4]. Unlike PG_has_hwpoisoned, which is only
> maintained for THP, this catches HWPoison pages in any high-order
> folio, including dissolved HugeTLB folios.

So thinking about this again (and hating the diffstat with passion) I think a
better temporary approach (until we sort this all out properly, eventually, ...
:) ) would be to set PG_has_hwpoisoned also for hugetlb.

I think your previous patches did that for dissolved hugetlb folios ...

Didn't Willy have some patches to do it properly for hugetlb? Yes indeed:

https://lore.kernel.org/all/20260805210557.1118966-9-willy@infradead.org/

Likely we could do it more minimally for the purpose of this stuff here by just
setting the flag?

Then, as a quick, less intrusive fix, exclude the entire thing from the buddy.
Don't free individual pages. Just stop that memory from reuse for now.

Of course, we might also be able to do that with PageHWPoison, but
PG_has_hwpoisoned would be a lot cleaner.

I don't think we want all that complicated "free parts of a broken folio" in a
commit that actually fixes something real (using hugetlb folios and handing them
back out again).

-- 
Cheers,

David

  parent reply	other threads:[~2026-12-02 16:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10  5:33 [PATCH v7 0/3] Only " Jiaqi Yan
2026-11-10  5:33 ` [PATCH v7 1/3] mm/page_alloc: free_prepared_contig_range() takes fpi_t Jiaqi Yan
2026-11-10  5:33 ` [PATCH v7 2/3] mm/page_alloc: only free healthy pages in high-order folio Jiaqi Yan
2026-11-26  7:15   ` Miaohe Lin
2026-11-30 22:39     ` Jiaqi Yan
2026-12-02  9:18       ` Miaohe Lin
2026-12-02 16:53   ` David Hildenbrand (Arm) [this message]
2026-11-10  5:33 ` [PATCH v7 3/3] selftests/mm: add hard memory failure anonymous HugeTLB test Jiaqi Yan

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=b6e83318-7964-45a5-8fca-5ff9c755d5a3@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=boudewijn@delta-utec.com \
    --cc=duenwen@google.com \
    --cc=hannes@cmpxchg.org \
    --cc=harry.yoo@oracle.com \
    --cc=jackmanb@google.com \
    --cc=jane.chu@oracle.com \
    --cc=jiaqiyan@google.com \
    --cc=jthoughton@google.com \
    --cc=liam@infradead.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=nao.horiguchi@gmail.com \
    --cc=osalvador@kernel.org \
    --cc=osalvador@suse.de \
    --cc=rientjes@google.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=tony.luck@intel.com \
    --cc=vbabka@kernel.org \
    --cc=vbabka@suse.cz \
    --cc=wangkefeng.wang@huawei.com \
    --cc=william.roche@oracle.com \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.com \
    /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

all inboxes | Powered by JetHome®