* [PATCH] mm: page_alloc: do not capture HIGHATOMIC pages
@ 2026-11-29 14:23 Qi Wu
2026-11-30 15:56 ` Harry Yoo
0 siblings, 1 reply; 2+ messages in thread
From: Qi Wu @ 2026-11-29 14:23 UTC (permalink / raw)
To: Vlastimil Babka, Johannes Weiner, Andrew Morton
Cc: Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Zi Yan,
Mel Gorman, linux-mm
compaction_capture() filters CMA and isolated pages but not
MIGRATE_HIGHATOMIC. A captured page bypasses the buddy freelists, so it
escapes the ALLOC_HIGHATOMIC check in rmqueue_buddy() and the
nr_free_highatomic watermark accounting: a plain blocking allocation
can consume a page reserved for atomic allocations. HIGHATOMIC pages
reach the hook through PCP drains, which re-read the pageblock type
before calling __free_one_page().
The gap has existed since capture was introduced; commit 7e8756d7ad22
("mm: page_alloc: fix non-movable reclaim storm in defrag_mode")
widened it by sending non-movable order-0 allocations through direct
compaction when defrag_mode is enabled.
Refuse HIGHATOMIC pages like CMA. The page then enters the freelists
and the allocation falls back to get_page_from_freelist(), where the
reserve checks apply.
Found and drafted with AI assistance (Qoder); build-tested only.
Fixes: 5e1f0f098b46 ("mm, compaction: capture a page under direct compaction")
Cc: stable@vger.kernel.org
Signed-off-by: Qi Wu <shijing.wuqi@linux.alibaba.com>
---
mm/page_alloc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2fef4092c913..4443d715df2d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -735,6 +735,10 @@ compaction_capture(struct capture_control *capc, struct page *page,
is_migrate_isolate(migratetype))
return false;
+ /* HIGHATOMIC pages are reserved for atomic allocations. */
+ if (migratetype == MIGRATE_HIGHATOMIC)
+ return false;
+
/*
* Do not let lower order allocations pollute a movable pageblock
* unless compaction is also requesting movable pages.
base-commit: 4f069ab1ec243e6b60dc438772905855c60774e8
Notes (not part of the commit log):
- Checked against akpm mm-unstable (890dc639d8a3): compaction_capture()
is identical there. The in-flight freetype_t rework and the
"claim blocks captured for non-movable use" RFC touch this function
but are not queued yet, so this applies cleanly to both trees.
- The hit rate of this path can be observed with the
mm_page_alloc_extfrag tracepoint (fallbackmt=HIGHATOMIC).
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm: page_alloc: do not capture HIGHATOMIC pages
2026-11-29 14:23 [PATCH] mm: page_alloc: do not capture HIGHATOMIC pages Qi Wu
@ 2026-11-30 15:56 ` Harry Yoo
0 siblings, 0 replies; 2+ messages in thread
From: Harry Yoo @ 2026-11-30 15:56 UTC (permalink / raw)
To: Qi Wu
Cc: Vlastimil Babka, Johannes Weiner, Andrew Morton,
Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Zi Yan,
Mel Gorman, linux-mm
On Sun, Nov 29, 2026 at 10:23:50PM +0800, Qi Wu wrote:
> compaction_capture() filters CMA and isolated pages but not
> MIGRATE_HIGHATOMIC. A captured page bypasses the buddy freelists, so it
> escapes the ALLOC_HIGHATOMIC check in rmqueue_buddy() and the
> nr_free_highatomic watermark accounting: a plain blocking allocation
> can consume a page reserved for atomic allocations. HIGHATOMIC pages
> reach the hook through PCP drains, which re-read the pageblock type
> before calling __free_one_page().
>
> The gap has existed since capture was introduced; commit 7e8756d7ad22
> ("mm: page_alloc: fix non-movable reclaim storm in defrag_mode")
> widened it by sending non-movable order-0 allocations through direct
> compaction when defrag_mode is enabled.
>
> Refuse HIGHATOMIC pages like CMA. The page then enters the freelists
> and the allocation falls back to get_page_from_freelist(), where the
> reserve checks apply.
>
> Found and drafted with AI assistance (Qoder); build-tested only.
The idea of this patch makes sense to me, but would you please at least
try to reproduce the problem before claiming it _fixes_ the problem :)
> Fixes: 5e1f0f098b46 ("mm, compaction: capture a page under direct compaction")
> Cc: stable@vger.kernel.org
... especially when backporting a patch to -stable.
> Signed-off-by: Qi Wu <shijing.wuqi@linux.alibaba.com>
> ---
> mm/page_alloc.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 2fef4092c913..4443d715df2d 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -735,6 +735,10 @@ compaction_capture(struct capture_control *capc, struct page *page,
> is_migrate_isolate(migratetype))
> return false;
>
> + /* HIGHATOMIC pages are reserved for atomic allocations. */
> + if (migratetype == MIGRATE_HIGHATOMIC)
> + return false;
> +
> /*
> * Do not let lower order allocations pollute a movable pageblock
> * unless compaction is also requesting movable pages.
>
> base-commit: 4f069ab1ec243e6b60dc438772905855c60774e8
>
> Notes (not part of the commit log):
> - Checked against akpm mm-unstable (890dc639d8a3): compaction_capture()
> is identical there. The in-flight freetype_t rework and the
> "claim blocks captured for non-movable use" RFC touch this function
> but are not queued yet, so this applies cleanly to both trees.
> - The hit rate of this path can be observed with the
> mm_page_alloc_extfrag tracepoint (fallbackmt=HIGHATOMIC).
> --
> 2.47.3
--
Cheers,
Harry / Hyeonggon
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-30 15:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 14:23 [PATCH] mm: page_alloc: do not capture HIGHATOMIC pages Qi Wu
2026-11-30 15:56 ` Harry Yoo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox