From: Zi Yan <ziy@nvidia.com>
To: David Hildenbrand <david@kernel.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
"Lorenzo Stoakes" <lorenzo.stoakes@oracle.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
"Vlastimil Babka" <vbabka@suse.cz>,
"Mike Rapoport" <rppt@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>,
"Miaohe Lin" <linmiaohe@huawei.com>,
"Naoya Horiguchi" <nao.horiguchi@gmail.com>,
"Zi Yan" <ziy@nvidia.com>, "Harry Yoo" <harry.yoo@oracle.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
"Yu Zhao" <yuzhao@google.com>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Wei Yang" <richard.weiyang@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
是参差 <shicenci@gmail.com>
Subject: [PATCH] mm/memory_failure: reject unsupported non-folio compound page
Date: Wed, 4 Feb 2026 19:56:03 -0500 [thread overview]
Message-ID: <20260205005603.274383-1-ziy@nvidia.com> (raw)
When !CONFIG_TRANSPARENT_HUGEPAGE, a non-folio compound page can appear in
a userspace mapping via either vm_insert_*() functions or
vm_operatios_struct->fault(). They are not folios, thus should not be
considered for folio operations like split. Change memory_failure() and
soft_offline_page() to reject these non-folio compound pages as
EOPNOTSUPP.
Add PageNonFolioCompound() helper function. This function is functionally
equivalent to folio_test_large() && !folio_test_large_rmappable(), but it
is supposed to be used on struct page. So open code it instead.
Fixes: 689b8986776c ("mm/memory-failure: improve large block size folio handling")
Reported-by: 是参差 <shicenci@gmail.com>
Closes: https://lore.kernel.org/all/PS1PPF7E1D7501F1E4F4441E7ECD056DEADAB98A@PS1PPF7E1D7501F.apcprd02.prod.outlook.com/
Signed-off-by: Zi Yan <ziy@nvidia.com>
---
include/linux/page-flags.h | 16 ++++++++++++++++
mm/memory-failure.c | 9 ++++++---
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index f7a0e4af0c73..2fe8047f42a3 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -1102,6 +1102,22 @@ static inline bool folio_contain_hwpoisoned_page(struct folio *folio)
bool is_free_buddy_page(const struct page *page);
+static inline bool PageNonFolioCompound(const struct page *page)
+{
+ if (PageCompound(page)) {
+ const struct page *head = compound_head(page);
+
+ /*
+ * Without CONFIG_TRANSPARENT_HUGEPAGE, PG_large_rmappable
+ * should not be set/used.
+ */
+ return !IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) ||
+ !test_bit(PG_large_rmappable, &head[1].flags.f);
+ }
+
+ return false;
+}
+
#ifdef CONFIG_MIGRATION
/*
* This page is migratable through movable_ops (for selected typed pages
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index cf0d526e6d41..8b6b5950bb66 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2440,9 +2440,12 @@ int memory_failure(unsigned long pfn, int flags)
folio = page_folio(p);
- /* filter pages that are protected from hwpoison test by users */
+ /*
+ * filter pages that are protected from hwpoison test by users or
+ * unsupported non folio compound ones
+ */
folio_lock(folio);
- if (hwpoison_filter(p)) {
+ if (hwpoison_filter(p) || PageNonFolioCompound(p)) {
ClearPageHWPoison(p);
folio_unlock(folio);
folio_put(folio);
@@ -2945,7 +2948,7 @@ int soft_offline_page(unsigned long pfn, int flags)
ret = get_hwpoison_page(page, flags | MF_SOFT_OFFLINE);
put_online_mems();
- if (hwpoison_filter(page)) {
+ if (hwpoison_filter(page) || PageNonFolioCompound(page)) {
if (ret > 0)
put_page(page);
--
2.51.0
next reply other threads:[~2026-02-05 0:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 0:56 Zi Yan [this message]
2026-02-05 3:25 ` Miaohe Lin
2026-02-05 3:40 ` Zi Yan
2026-02-05 3:51 ` Harry Yoo
2026-02-05 3:34 ` Harry Yoo
2026-02-05 3:56 ` Zi 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=20260205005603.274383-1-ziy@nvidia.com \
--to=ziy@nvidia.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=harry.yoo@oracle.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=nao.horiguchi@gmail.com \
--cc=richard.weiyang@gmail.com \
--cc=rppt@kernel.org \
--cc=shicenci@gmail.com \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
--cc=yuzhao@google.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