From: "Gregory Price (Meta)" <gourry@gourry.net>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org,
kernel-team@meta.com, akpm@linux-foundation.org,
vbabka@kernel.org, surenb@google.com, mhocko@suse.com,
brendan.jackman@linux.dev, hannes@cmpxchg.org, ziy@nvidia.com,
linmiaohe@huawei.com, nao.horiguchi@gmail.com, david@kernel.org,
ljs@kernel.org, liam@infradead.org, rppt@kernel.org,
osalvador@suse.de, muchun.song@linux.dev, iamjoonsoo.kim@lge.com,
anshuman.khandual@arm.com
Subject: [PATCH 0/6] mm: fix pfn walker races with memory offline
Date: Tue, 27 Oct 2026 00:21:58 -0400 [thread overview]
Message-ID: <20261027042204.3741307-1-gourry@gourry.net> (raw)
Several pfn walkers check that a struct page is online, then use it
after memory offline has poisoned it (CONFIG_DEBUG_VM) or removal has
freed the vmemmap. Five of the races crash the kernel; the sixth leaves
an offline spinning with the device hotplug lock held.
Patch 1 adds pfn_walk, an SRCU-fast read section that offline waits for
before poisoning the memmap. Patches 2 and 5 use it; patches 3 and 6
hold get_online_mems() instead.
1. compaction scanners
2. page_owner reads
3. memory_failure(), soft_offline_page(), unpoison_memory()
4. alloc_contig_range() undoing another caller's isolation
5. alloc_contig_pages() isolating a range that went offline
6. the hwpoison-inject filter
All six are for stable.
Patches 2 and 5 need patch 1
patch 5 builds on patch 4
patch 6 builds on patch 3
Testing
=======
Each race was reproduced on unmodified source in a QEMU guest with three
NUMA nodes and a pc-dimm left offline at boot (DEBUG_VM, KASAN,
lockdep). A test module holds one task inside the window while the
offline or eject runs, then releases it.
base this series
patch outcome runs outcome runs
----- ---------------------- ----- ---------------------- -----
1 GPF 3/3 offline waits, clean 3/3
2 GPF or #PF 6/6 offline waits, clean 6/6
3 GPF, or unpoison of a 9/9 blocks, -EIO/-ENXIO 9/9
poisoned page
4 offline still looping 4/4 offline completes 3/3
after 30s
5 GPF 3/3 offline waits, clean 6/6
6 #PF 3/3 eject waits, -ENXIO 3/3
Without forcing the window, offline/online cycling under compaction
faulted in 8 of 24 runs on base and 0 of 12 with patch 1.
Cost
====
I was unable to measure a discernable cost beyond noise, stddev of
walkers and scanners runtimes on real hardware was wildly inconsistent.
Leads me to believe this change is largely imperceivable.
Gregory Price (Meta) (6):
mm/compaction: wait for pfn walkers before poisoning offlined memmap
mm/page_owner: hold off memory offline while a page is read
mm/memory-failure: keep the page online while handling it
mm/page_alloc: don't undo another isolation in alloc_contig_range
mm/page_alloc: keep the range online while alloc_contig isolates it
mm/hwpoison-inject: keep the page online while filtering it
mm/compaction.c | 8 +++++++
mm/hwpoison-inject.c | 55 +++++++++++++++++++++++++++++---------------
mm/internal.h | 41 +++++++++++++++++++++++++++++++++
mm/memory-failure.c | 31 +++++++++++++++++--------
mm/memory_hotplug.c | 16 +++++++++++--
mm/mm_init.c | 4 ++--
mm/page_alloc.c | 35 +++++++++++++++++++++++++---
mm/page_alloc.h | 7 +++++-
mm/page_owner.c | 45 +++++++++++++++++++-----------------
9 files changed, 186 insertions(+), 56 deletions(-)
--
2.53.0-Meta
next reply other threads:[~2026-10-27 4:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 4:21 Gregory Price (Meta) [this message]
2026-10-27 4:21 ` [PATCH 1/6] mm/compaction: wait for pfn walkers before poisoning offlined memmap Gregory Price (Meta)
2026-10-27 13:38 ` David Hildenbrand (Arm)
2026-10-27 4:22 ` [PATCH 2/6] mm/page_owner: hold off memory offline while a page is read Gregory Price (Meta)
2026-10-27 4:22 ` [PATCH 3/6] mm/memory-failure: keep the page online while handling it Gregory Price (Meta)
2026-10-27 4:22 ` [PATCH 4/6] mm/page_alloc: don't undo another isolation in alloc_contig_range Gregory Price (Meta)
2026-10-27 13:37 ` David Hildenbrand (Arm)
2026-10-27 14:06 ` Gregory Price (Meta)
2026-10-27 14:13 ` David Hildenbrand (Arm)
2026-10-27 18:53 ` Zi Yan
2026-10-27 18:58 ` David Hildenbrand (Arm)
2026-10-27 19:38 ` Gregory Price
2026-10-27 4:22 ` [PATCH 5/6] mm/page_alloc: keep the range online while alloc_contig isolates it Gregory Price (Meta)
2026-10-27 4:22 ` [PATCH 6/6] mm/hwpoison-inject: keep the page online while filtering it Gregory Price (Meta)
2026-10-27 8:57 ` [PATCH 0/6] mm: fix pfn walker races with memory offline David Hildenbrand (Arm)
2026-10-27 11:31 ` Gregory Price (Meta)
2026-10-27 12:51 ` David Hildenbrand (Arm)
2026-10-27 13:49 ` Gregory Price (Meta)
2026-10-27 14:25 ` David Hildenbrand (Arm)
2026-10-27 15:49 ` Gregory Price (Meta)
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=20261027042204.3741307-1-gourry@gourry.net \
--to=gourry@gourry.net \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=brendan.jackman@linux.dev \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=kernel-team@meta.com \
--cc=liam@infradead.org \
--cc=linmiaohe@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.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
all inboxes | Powered by JetHome®