From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: "Gregory Price (Meta)" <gourry@gourry.net>,
Zi Yan <ziy@nvidia.com>,
"Vlastimil Babka (SUSE)" <vbabka@kernel.org>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1.y] mm/page_alloc: don't undo another isolation in alloc_contig_range
Date: Tue, 24 Nov 2026 15:27:28 -0500 [thread overview]
Message-ID: <20261124202645.2592499-1-sashal@kernel.org> (raw)
In-Reply-To: <2026112445-quartet-reseal-bdc1@gregkh>
From: "Gregory Price (Meta)" <gourry@gourry.net>
[ Upstream commit 7d9c29ed8feec8bfbe5e5f673ba2b5926da11375 ]
An alloc_contig_range() that overlaps a block going offline can leave
the offline spinning until it gets a signal, holding the device hotplug
lock. When isolation fails, alloc_contig_frozen_range() undoes it over
the whole range, clearing the offline's MIGRATE_ISOLATE too:
CPU 1 (offline_pages) CPU 2 (alloc_contig_range)
start_isolate_page_range()
blocks are MIGRATE_ISOLATE
start_isolate_page_range()
-EBUSY on CPU 1's blocks
undo_isolate_page_range()
blocks are MIGRATE_MOVABLE
test_pages_isolated()
never succeeds again
start_isolate_page_range() fails only on a block someone else isolated,
after undoing its own, so this undo only ever clears another caller's.
Return directly, as before alloc_contig_range() went pageblock granular.
With offline_pages() parked after isolating a DIMM block and a 1G
hugetlb allocation made over it, the offline on base still loops 30s
later in 4 of 4 runs:
offline_pages+0x5b2/0x1570
memory_subsys_offline+0x17e/0x470
device_offline+0x250/0x340
state_store+0x88/0x110
With this patch the allocation still fails, and the offline completes in
3 of 3 runs.
Fixes: b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity")
Cc: stable@vger.kernel.org
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Link: https://patch.msgid.link/20261027042204.3741307-5-gourry@gourry.net
Reviewed-by: Zi Yan <ziy@nvidia.com>
Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
[ sashal: Adapted the change to alloc_contig_range(), where start_isolate_page_range() takes migratetype, 0, and gfp_mask instead of mode. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
mm/page_alloc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ba7f386331a65..155029b96bf7e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -9328,9 +9328,13 @@ int alloc_contig_range(unsigned long start, unsigned long end,
* put back to page allocator so that buddy can use them.
*/
+ /*
+ * On failure this has undone its own isolation, and any other
+ * isolated blocks in the range belong to someone else, e.g. offline.
+ */
ret = start_isolate_page_range(start, end, migratetype, 0, gfp_mask);
if (ret)
- goto done;
+ return ret;
drain_all_pages(cc.zone);
--
2.53.0
prev parent reply other threads:[~2026-11-24 20:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 15:38 FAILED: patch "[PATCH] mm/page_alloc: don't undo another isolation in" failed to apply to 6.1-stable tree gregkh
2026-11-24 20:27 ` Sasha Levin [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=20261124202645.2592499-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=gourry@gourry.net \
--cc=stable@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.