From: Matthew Wilcox <willy@infradead.org>
To: Gregory Price <gourry@gourry.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jane Chu <jane.chu@oracle.com>,
linux-mm@kvack.org, Muchun Song <muchun.song@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
David Hildenbrand <david@kernel.org>,
Miaohe Lin <linmiaohe@huawei.com>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org,
Christian Brauner <christian@brauner.io>,
Jiaqi Yan <jiaqiyan@google.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v7 01/13] memory-failure: Fix hardware poison check in unpoison_memory() again
Date: Wed, 29 Jul 2026 02:43:27 +0100 [thread overview]
Message-ID: <amlav1zfVy-9fLw5@casper.infradead.org> (raw)
In-Reply-To: <amlKHkemYQBxFESG@gourry-fedora-PF4VCD3F>
On Tue, Jul 28, 2026 at 08:39:29PM -0400, Gregory Price wrote:
> On Tue, Jul 28, 2026 at 09:43:53PM +0100, Matthew Wilcox (Oracle) wrote:
> > The earlier patch (6c54312f9689) that attempted to fix unpoison_memory()
> > was incorrect for hugetlb folios. Before a6fddef49eef, we checked
> > the head page for poison (which was correct for hugetlb and incorrect
> > for THP). We are currently incapable of unpoisoning pages (other than
> > the first page) in a hugetlb folio.
> >
> > Use is_page_hwpoison() which handles hugetlb pages sufficiently well for
> > this purpose. This is racy as we don't have a reference on the folio at
> > this point, but fixing that properly requires deeper surgery and this
> > is a CAP_SYS_ADMIN path only so this will do for the moment and can be
> > easily backported. It's no worse than the situation before a6fddef49eef.
> >
> > The other bug in a6fddef49eef is that we currently clear the HWPoison
> > flag on the precise page, which is wrong for hugetlb. Fix that too.
> >
> > Fixes: a6fddef49eef ("mm/memory-failure: convert unpoison_memory() to folios")
> > Cc: stable@vger.kernel.org
> > Cc: Miaohe Lin <linmiaohe@huawei.com>
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
>
> Just trying to wrap my head around the state before/after, assuming
> the following is correct then LGTM:
>
> prior:
> pfn_to_online_page(pfn) -> p = precise page
> PageHWPoison(page) -> checks precise page. Poison for hugetlb
> is only set only on the head, so bug.
> after:
> is_page_hwpoison(page) -> checks precise page AND head (if hugetlb)
> p = folio->page -> now TestClearPageHWPoison() explicitly
> clears the head page poison if hugetlb
Exactly. That was how it worked before a6fddef49eef; it used to do
p = compound_head(p) (which wasn't great _either_ but had different
problems ...)
The careful reader will observe that injecting two memory failures
into the same hugetlb causes ... problems. That's true before and after
this patch, so it's no longer a regression.
> Reviewed-by: Gregory Price (Meta) <gourry@gourry.net>
>
next prev parent reply other threads:[~2026-07-29 1:43 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 20:43 [PATCH v7 00/13] Use generic_file_read_iter() in hugetlbfs Matthew Wilcox (Oracle)
2026-07-28 20:43 ` [PATCH v7 01/13] memory-failure: Fix hardware poison check in unpoison_memory() again Matthew Wilcox (Oracle)
2026-07-29 0:39 ` Gregory Price
2026-07-29 1:43 ` Matthew Wilcox [this message]
2026-07-30 8:45 ` Miaohe Lin
2026-07-31 20:00 ` Matthew Wilcox
2026-07-31 5:39 ` jane.chu
2026-07-31 13:39 ` Matthew Wilcox
2026-07-31 17:36 ` jane.chu
2026-07-28 20:43 ` [PATCH v7 02/13] mm: Rename folio_contain_hwpoison_page() to folio_has_hwpoison_page() Matthew Wilcox (Oracle)
2026-07-30 8:53 ` Miaohe Lin
2026-07-31 6:07 ` jane.chu
2026-07-28 20:43 ` [PATCH v7 03/13] hugetlb: Mark some function arguments as const Matthew Wilcox (Oracle)
2026-07-30 8:57 ` Miaohe Lin
2026-07-28 20:43 ` [PATCH v7 04/13] guest_memfd: Use folio_has_hwpoisoned_page() Matthew Wilcox (Oracle)
2026-07-28 20:43 ` [PATCH v7 05/13] hugetlb: Move poison to pages before clearing hugetlb page type Matthew Wilcox (Oracle)
2026-07-29 0:41 ` Gregory Price
2026-07-30 11:40 ` Miaohe Lin
2026-07-28 20:43 ` [PATCH v7 06/13] hugetlb: Use the has_hwpoisoned flag Matthew Wilcox (Oracle)
2026-07-29 1:36 ` Gregory Price
2026-07-29 2:55 ` Matthew Wilcox
2026-07-29 15:05 ` Matthew Wilcox
2026-07-29 16:45 ` Gregory Price
2026-07-28 20:43 ` [PATCH v7 07/13] mm: Remove locking mf_mutex in is_raw_hwpoison_page_in_hugepage() Matthew Wilcox (Oracle)
2026-07-28 20:44 ` [PATCH v7 08/13] mm: Check individual hugetlb pages for poison Matthew Wilcox (Oracle)
2026-07-28 20:44 ` [PATCH v7 09/13] filemap: Add hwpoison handling to filemap_read() Matthew Wilcox (Oracle)
2026-07-28 20:44 ` [PATCH v7 10/13] filemap: Remove checks in mapping_set_folio_order_range() Matthew Wilcox (Oracle)
2026-07-28 20:44 ` [PATCH v7 11/13] hugetlb: Set mapping folio order Matthew Wilcox (Oracle)
2026-07-28 20:44 ` [PATCH v7 12/13] filemap: Add support for authoritative mappings Matthew Wilcox (Oracle)
2026-07-28 20:44 ` [PATCH v7 13/13] hugetlb: replace hugetlbfs_read_iter() with generic_file_read_iter() Matthew Wilcox (Oracle)
2026-07-29 15:17 ` [PATCH v7 00/13] Use generic_file_read_iter() in hugetlbfs Matthew Wilcox
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=amlav1zfVy-9fLw5@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=christian@brauner.io \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=jack@suse.cz \
--cc=jane.chu@oracle.com \
--cc=jiaqiyan@google.com \
--cc=linmiaohe@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=stable@vger.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