From: Mani Tofigh <mt4022@columbia.edu>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: David Hildenbrand <david@kernel.org>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
Kiryl Shutsemau <kas@kernel.org>, Mike Rapoport <rppt@kernel.org>,
Mike Kravetz <mike.kravetz@oracle.com>,
Matthew Wilcox <willy@infradead.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
tz2294@columbia.edu, stable@vger.kernel.org,
Muchun Song <muchun.song@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v3] mm/memory-failure: set PG_hwpoison of a non-hugetlb page under hugetlb_lock
Date: Wed, 11 Nov 2026 18:21:59 -0500 [thread overview]
Message-ID: <a87cbd92-0e07-4f84-9a6f-8db0b1778fcf@columbia.edu> (raw)
In-Reply-To: <42a60f57-5323-f981-8ef3-2e5d67623902@huawei.com>
On 11/9/26 2:23 AM, Miaohe Lin wrote:
> I have no idea why the error on P itself is ignored, could you explain that?
My bad, I should have explained that. By then P is part of a hugetlb
folio that's still free or being set up, so get_hwpoison_page() can't
take it and we just end with "Ignored". Nothing marks the folio, so
the bad page goes back to the pool and gets handed out later.
If the folio is already in use it's even worse... it gets split as a
THP and hangs. (That's a different race though, I'll send a separate
fix for that soon.)
> I think we should clear the PageHWPoison flag we just set since the retry path expects
> we have cleared the PageHWPoison flag in the first round.
Agreed, as long as the page still isn't hugetlb. Once it is, HVO may
have remapped its struct page, so the clear either hits the shared tail
page (read-only on e.g. 6.6) or gets lost while HVO copies the first
vmemmap page.
So how about clearing it under hugetlb_lock only if the page still isn't
hugetlb, and otherwise skipping the retry like the second round does?
> I suspect this won’t solve the problem. The below race might still exist:
>
> Task A (memory_failure) Task B (nr_hugepages write)
> get_huge_page_for_hwpoison() alloc_fresh_hugetlb_folio()
> /* P not hugetlb */ /* P becomes a tail page */
> clear_non_hugetlb_hwpoison
> goto retry
> get_huge_page_for_hwpoison()
> /* P not hugetlb */
> __folio_set_hugetlb
> hugetlb_vmemmap_optimize_folio()
> /* P's struct page now in
> the shared tail page */
> TestSetPageHWPoison(P)
I think that one's covered. With the patch, the "not hugetlb" check and
TestSetPageHWPoison() are under the same hugetlb_lock, and
__folio_set_hugetlb() moves under hugetlb_lock too, before HVO. So A
either sees P as hugetlb, or the flag lands in P's OWN struct page
before HVO gets to it.
Also, with Muchun's vmemmap_remap_rwsem [1] HVO waits for
get_huge_page_for_hwpoison() anyway, so if his series goes in first the
hugetlb.c part can go.
[1]
https://lore.kernel.org/all/20261111093747.50048-2-songmuchun@bytedance.com/
Mani
prev parent reply other threads:[~2026-11-11 23:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 16:09 Mani Tofigh via B4 Relay
2026-11-06 22:39 ` Andrew Morton
2026-11-09 11:29 ` Miaohe Lin
2026-11-09 7:23 ` Miaohe Lin
2026-11-11 23:21 ` Mani Tofigh [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=a87cbd92-0e07-4f84-9a6f-8db0b1778fcf@columbia.edu \
--to=mt4022@columbia.edu \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=kas@kernel.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=rppt@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tz2294@columbia.edu \
--cc=willy@infradead.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
all inboxes | Powered by JetHome®