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

From: David Hildenbrand (Arm)

Date: Wed Nov 18 2026 - 04:50:53 EST


On 11/18/26 01:00, Daniil Tatianin wrote:
> 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);
>

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7d9c29ed8feec8bfbe5e5f673ba2b5926da11375

--
Cheers,

David