From: Jiaqi Yan <jiaqiyan@google.com>
To: ljs@kernel.org, linmiaohe@huawei.com, osalvador@kernel.org,
ziy@nvidia.com, harry.yoo@oracle.com, willy@infradead.org
Cc: osalvador@suse.de, lorenzo.stoakes@oracle.com,
jackmanb@google.com, hannes@cmpxchg.org,
nao.horiguchi@gmail.com, david@kernel.org,
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, Jiaqi Yan <jiaqiyan@google.com>
Subject: [PATCH v5 3/4] mm/memory-failure: skip take_page_off_buddy after dissolving HWPoison HugeTLB page
Date: Sun, 31 May 2026 05:58:28 +0000 [thread overview]
Message-ID: <20260531055829.3636554-4-jiaqiyan@google.com> (raw)
In-Reply-To: <20260531055829.3636554-1-jiaqiyan@google.com>
Now that HWPoison subpage(s) within HugeTLB page will be rejected by
buddy allocator during dissolve_free_hugetlb_folio(), there is no
need to drain_all_pages() and take_page_off_buddy() anymore. In fact,
calling take_page_off_buddy() after dissolve_free_hugetlb_folio()
succeeded returns false, making caller think __page_handle_poison()
failed.
Add __hugepage_handle_poison() and replace __page_handle_poison() at
HugeTLB specific call sites. The being handled HugeTLB page either
is free at the moment of try_memory_failure_hugetlb(), or becomes
free at the moment of me_huge_page().
Signed-off-by: Jiaqi Yan <jiaqiyan@google.com>
---
mm/memory-failure.c | 36 ++++++++++++++++++++++++++++++------
1 file changed, 30 insertions(+), 6 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 95979b7995c1..098c4407e818 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -163,6 +163,30 @@ static struct rb_root_cached pfn_space_itree = RB_ROOT_CACHED;
static DEFINE_MUTEX(pfn_space_lock);
/*
+ * Only for a HugeTLB page being handled by memory_failure(). The key
+ * difference to soft_offline() is that, no HWPoison subpage will make
+ * into buddy allocator after a successful dissolve_free_hugetlb_folio(),
+ * so take_page_off_buddy() is unnecessary.
+ */
+static int __hugepage_handle_poison(struct page *page)
+{
+ struct folio *folio = page_folio(page);
+
+ VM_WARN_ON_FOLIO(!folio_test_hwpoison(folio), folio);
+
+ /*
+ * Can't use dissolve_free_hugetlb_folio() without a reliable
+ * raw_hwp_list telling which subpage is HWPoison.
+ */
+ if (folio_test_hugetlb_raw_hwp_unreliable(folio))
+ /* raw_hwp_list becomes unreliable when kmalloc() fails. */
+ return -ENOMEM;
+
+ return dissolve_free_hugetlb_folio(folio);
+}
+
+/*
+ * Only for a free or HugeTLB page being handled by soft_offline().
* Return values:
* 1: the page is dissolved (if needed) and taken off from buddy,
* 0: the page is dissolved (if needed) and not taken off from buddy,
@@ -1166,11 +1190,11 @@ static int me_huge_page(struct page_state *ps, struct page *p)
* subpages.
*/
folio_put(folio);
- if (__page_handle_poison(p) > 0) {
+ if (__hugepage_handle_poison(p)) {
+ res = MF_FAILED;
+ } else {
page_ref_inc(p);
res = MF_RECOVERED;
- } else {
- res = MF_FAILED;
}
}
@@ -2076,11 +2100,11 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags)
*/
if (res == MF_HUGETLB_FREED) {
folio_unlock(folio);
- if (__page_handle_poison(p) > 0) {
+ if (__hugepage_handle_poison(p)) {
+ res = MF_FAILED;
+ } else {
page_ref_inc(p);
res = MF_RECOVERED;
- } else {
- res = MF_FAILED;
}
return action_result(pfn, MF_MSG_FREE_HUGE, res);
}
--
2.54.0.823.g6e5bcc1fc9-goog
next prev parent reply other threads:[~2026-05-31 5:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-31 5:58 [PATCH v5 0/4] Only free healthy pages in high-order has_hwpoisoned folio Jiaqi Yan
2026-05-31 5:58 ` [PATCH v5 1/4] mm/page_alloc: only " Jiaqi Yan
2026-06-09 3:44 ` Miaohe Lin
2026-06-12 18:34 ` Zi Yan
[not found] ` <CACw3F51hi1SAs264i0FKMbieOQhCpRQQ9s7gS_cHDYgHsqu0WQ@mail.gmail.com>
2026-06-17 1:56 ` Zi Yan
2026-06-18 14:52 ` Vlastimil Babka (SUSE)
2026-06-18 16:04 ` Zi Yan
[not found] ` <ce2f2cea-1451-09a4-4562-62808b1c2d93@huawei.com>
2026-06-18 15:02 ` Vlastimil Babka (SUSE)
2026-06-15 2:03 ` Jiaqi Yan
2026-05-31 5:58 ` [PATCH v5 2/4] mm/memory-failure: set has_hwpoisoned flags on dissolved HugeTLB folio Jiaqi Yan
2026-06-09 6:34 ` Miaohe Lin
2026-05-31 5:58 ` Jiaqi Yan [this message]
2026-06-09 7:21 ` [PATCH v5 3/4] mm/memory-failure: skip take_page_off_buddy after dissolving HWPoison HugeTLB page Miaohe Lin
2026-06-15 0:16 ` Jiaqi Yan
2026-05-31 5:58 ` [PATCH v5 4/4] selftests/mm: add hard memory failure anonymous 1G HugeTLB page test Jiaqi Yan
2026-06-01 18:04 ` Jiaqi Yan
2026-06-17 7:38 ` Miaohe Lin
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=20260531055829.3636554-4-jiaqiyan@google.com \
--to=jiaqiyan@google.com \
--cc=akpm@linux-foundation.org \
--cc=boudewijn@delta-utec.com \
--cc=david@kernel.org \
--cc=duenwen@google.com \
--cc=hannes@cmpxchg.org \
--cc=harry.yoo@oracle.com \
--cc=jackmanb@google.com \
--cc=jane.chu@oracle.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=lorenzo.stoakes@oracle.com \
--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@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