From: Matthew Wilcox <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>,
Jane Chu <jane.chu@oracle.com>,
linux-mm@kvack.org
Cc: 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>,
Usama Arif <usama.arif@linux.dev>
Subject: Re: [PATCH v5 02/12] mm: Rename folio_contain_hwpoison_page() to folio_has_hwpoison_page()
Date: Mon, 27 Jul 2026 15:51:29 +0100 [thread overview]
Message-ID: <amdwca1VRNPjEl8j@casper.infradead.org> (raw)
In-Reply-To: <20260725160042.1557264-3-willy@infradead.org>
Sashiko review:
> --- Patch [2]: [PATCH v5 02/12] mm: Rename folio_contain_hwpoison_page() to folio_has_hwpoison_page() ---
> commit 8fadf59bc3118e11dab2620f6cc376507c16b29a
> Author: Matthew Wilcox (Oracle) <willy@infradead.org>
>
> mm: Rename folio_contain_hwpoison_page() to folio_has_hwpoison_page()
>
> This is a better name for this predicate. Also make the argument const
> to allow other callers to be made const. No functional change.
>
> > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
> > index 7223f6f4e2b40..4185a03a45cf7 100644
> > --- a/include/linux/page-flags.h
> > +++ b/include/linux/page-flags.h
> > @@ -1083,10 +1083,10 @@ static inline bool is_page_hwpoison(const struct page *page)
> > return folio_test_hugetlb(folio) && PageHWPoison(&folio->page);
> > }
> >
> > -static inline bool folio_contain_hwpoisoned_page(struct folio *folio)
> > +static inline bool folio_has_hwpoisoned_page(const struct folio *folio)
> > {
> > return folio_test_hwpoison(folio) ||
> > - (folio_test_large(folio) && folio_test_has_hwpoisoned(folio));
> > + (folio_test_large(folio) && folio_test_has_hwpoisoned(folio));
> > }
>
> This isn't a bug introduced by this patch, but can KSM trigger a machine check
> exception when scanning memory?
Good lord. I renamed a function. Which apparently causes Sashiko to
look for bugs in every caller
> Looking at cmp_and_merge_page() in mm/ksm.c, the KSM scanner initiates page
> hash calculation:
>
> mm/ksm.c:cmp_and_merge_page() {
> ...
> checksum = calc_checksum(page);
> ...
> }
>
> which then maps and reads the page content:
>
> mm/ksm.c:calc_checksum() {
> ...
> void *addr = kmap_local_page(page);
> checksum = xxhash(addr, PAGE_SIZE, 0);
> ...
> }
>
> If a page becomes hardware-poisoned before KSM scans it, shouldn't there be a
> PageHWPoison(page) or folio_has_hwpoisoned_page(folio) check before the read
> to prevent a fatal MCE?
>
>
> This is a pre-existing issue, but does migration risk panicking on poisoned
> memory?
Yes, lots of things risk panicking on poisoned memory. It's never been
a priority for Linux.
> During page migration, pages are passed to __migrate_folio() which copies the
> contents without validation:
>
> mm/migrate.c:__migrate_folio() {
> ...
> rc = folio_mc_copy(dst, src);
> if (unlikely(rc))
> return rc;
> ...
> }
>
> This executes the page copy in folio_mc_copy():
>
> mm/util.c:folio_mc_copy() {
> ...
> if (copy_mc_highpage(folio_page(dst, i), folio_page(src, i)))
> return -EHWPOISON;
> ...
> }
>
> On architectures lacking copy_mc support, this falls back to copy_highpage().
> Without a prior folio_has_hwpoisoned_page(src) check, could migrating a
> poisoned page via mbind() or move_pages() read poisoned memory and trigger a
> kernel panic?
>
>
> This is a pre-existing issue, but does kill_accessing_process() return the
> wrong error code when a task lacks an mm?
>
> In memory failure handling, if the task is exiting or is a kernel thread,
> p->mm is NULL:
>
> mm/memory-failure.c:kill_accessing_process() {
> ...
> if (!p->mm)
> return -EFAULT;
> ...
> }
>
> Since the memory_failure() API protocol requires returning 0 for a successfully
> recovered state (no user signal needed), does returning -EFAULT cause the
> architecture MCE handler, such as kill_me_maybe(), to erroneously conclude
> recovery failed? Could this trigger unnecessary warnings and incorrectly
> attempt to force a SIGBUS on the dying task?
Dunno, and I'm done with side-quests. Somebody else can decide if this
is a real problem that needs to be fixed.
next prev parent reply other threads:[~2026-07-27 14:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 16:00 [PATCH v5 00/12] Use generic_file_read_iter() in hugetlbfs Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 01/12] memory-failure: Fix hardware poison check in unpoison_memory() again Matthew Wilcox (Oracle)
2026-07-27 14:43 ` Matthew Wilcox
2026-07-27 19:40 ` Andrew Morton
2026-07-25 16:00 ` [PATCH v5 02/12] mm: Rename folio_contain_hwpoison_page() to folio_has_hwpoison_page() Matthew Wilcox (Oracle)
2026-07-27 14:51 ` Matthew Wilcox [this message]
2026-07-25 16:00 ` [PATCH v5 03/12] hugetlb: Mark some function arguments as const Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 04/12] guest_memfd: Use folio_has_hwpoisoned_page() Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 05/12] hugetlb: Use the has_hwpoisoned flag Matthew Wilcox (Oracle)
2026-07-27 15:19 ` Matthew Wilcox
2026-07-25 16:00 ` [PATCH v5 06/12] mm: Remove locking mf_mutex in is_raw_hwpoison_page_in_hugepage() Matthew Wilcox (Oracle)
2026-07-27 15:32 ` Matthew Wilcox
2026-07-25 16:00 ` [PATCH v5 07/12] mm: Check individual hugetlb pages for poison Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 08/12] filemap: Add hwpoison handling to filemap_read() Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 09/12] filemap: Remove checks in mapping_set_folio_order_range() Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 10/12] hugetlb: Set mapping folio order Matthew Wilcox (Oracle)
2026-07-25 16:00 ` [PATCH v5 11/12] filemap: Add support for authoritative mappings Matthew Wilcox (Oracle)
2026-07-27 15:55 ` Matthew Wilcox
2026-07-25 16:00 ` [PATCH v5 12/12] hugetlb: replace hugetlbfs_read_iter() with generic_file_read_iter() Matthew Wilcox (Oracle)
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=amdwca1VRNPjEl8j@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=christian@brauner.io \
--cc=david@kernel.org \
--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=usama.arif@linux.dev \
/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