Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zi Yan" <ziy@nvidia.com>
To: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>,
	"Dev Jain" <dev.jain@arm.com>,
	"Qi Wu" <shijing.wuqi@linux.alibaba.com>,
	"Johannes Weiner" <hannes@cmpxchg.org>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Kiryl Shutsemau" <kas@kernel.org>
Cc: "Suren Baghdasaryan" <surenb@google.com>,
	"Michal Hocko" <mhocko@suse.com>,
	"Brendan Jackman" <brendan.jackman@linux.dev>,
	"Mel Gorman" <mgorman@techsingularity.net>, <linux-mm@kvack.org>
Subject: Re: [PATCH] mm: page_alloc: do not capture HIGHATOMIC pages
Date: Thu, 03 Dec 2026 12:05:53 -0500	[thread overview]
Message-ID: <DNB9FFSLL159.2Z1UJ6BMHJ5DB@nvidia.com> (raw)
In-Reply-To: <3eec3d9b-bea3-4deb-ad2d-7ece5b85cf4f@kernel.org>

On Thu Dec 3, 2026 at 6:03 AM EST, Vlastimil Babka (SUSE) wrote:
> On 12/3/26 09:34, Dev Jain wrote:
>> 
>> 
>> On 29/11/26 7:53 pm, 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.
>>> 
>>> 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>
>>> ---
>> 
>> I think the main bug is about policy: IIUC a non-highatomic request currently
>> is able to take a highatomic page only via the PCP. Once we are in the
>> zone a highatomic page can be taken only by highatomic request.
>> 
>> So with that in mind I think this patch is correct for its scope:
>> 
>> Reviewed-by: Dev Jain <dev.jain@arm.com>
>> 
>> But the bigger question is, compaction_capture() captures a page for an allocation,
>> with no context as to who will consume that page. So for example with an
>> ALLOC_NOFRAGMENT request, we could mix allocations in pageblocks.
>> 
>> So perhaps there should be a check after looking up capc->page, whether
>> this is suitable for our allocation.

If the page is not suitable,  capc->page is freed? Or we hold the page
until a suitable allocation comes up.

Probably we should put more info in capture_control, so
compaction_capture() can make right decisions.

>
> Let's CC Kiryl then...
>
>> 
>>>  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).
>> 




-- 
Best Regards,
Yan, Zi



      reply	other threads:[~2026-12-03 17:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 14:23 [PATCH] mm: page_alloc: do not capture HIGHATOMIC pages Qi Wu
2026-11-30 15:56 ` Harry Yoo
2026-12-02  6:08   ` Qi Wu
2026-12-03  8:34 ` Dev Jain
2026-12-03 11:03   ` Vlastimil Babka (SUSE)
2026-12-03 17:05     ` Zi Yan [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=DNB9FFSLL159.2Z1UJ6BMHJ5DB@nvidia.com \
    --to=ziy@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=brendan.jackman@linux.dev \
    --cc=dev.jain@arm.com \
    --cc=hannes@cmpxchg.org \
    --cc=kas@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=mhocko@suse.com \
    --cc=shijing.wuqi@linux.alibaba.com \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /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