[PATCH] mm/page_alloc: don't undo another caller's pageblock isolation

From: Daniil Tatianin

Date: Tue Nov 17 2026 - 19:00:40 EST


start_isolate_page_range() fails with -EBUSY when a pageblock in the
range is already isolated, after it has undone the isolation it did
itself. Commit 2c7452a075d4 ("mm/page_isolation.c: make
start_isolate_page_range() fail if already isolated") made it work this
way, so that users of overlapping ranges, such as CMA, memory offlining
and gigantic hugetlb pages, can use pageblock isolation to stay out of
each other's way.

Since commit b2c9e2fbba32 ("mm: make alloc_contig_range work at
pageblock granularity"), alloc_contig_frozen_range() handles this
failure by jumping to its common exit path, which calls
undo_isolate_page_range() on the whole range. What is still isolated
there at this point belongs to the other user, so this takes the
isolation away while that user is still working on the pageblock. The
page allocator can then hand out its free pages again.

Return right away instead, like offline_pages() does when
start_isolate_page_range() fails.

Fixes: b2c9e2fbba32 ("mm: make alloc_contig_range work at pageblock granularity")
Signed-off-by: Daniil Tatianin <d-tatianin@xxxxxxxxxxxxxx>
---
mm/page_alloc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 12fac9084c48..151a8d64783d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7335,8 +7335,9 @@ int alloc_contig_frozen_range_noprof(unsigned long start, unsigned long end,
*/

ret = start_isolate_page_range(start, end, mode);
+ /* After a failure, whatever is still isolated belongs to someone else */
if (ret)
- goto done;
+ return ret;

drain_all_pages(cc.zone);