From: Kiryl Shutsemau <kas@kernel.org>
To: Harry Yoo <harry@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>,
David Hildenbrand <david@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <brendan.jackman@linux.dev>,
Zi Yan <ziy@nvidia.com>, Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Mike Rapoport <rppt@kernel.org>, Qi Zheng <qi.zheng@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Kairui Song <kasong@tencent.com>, Barry Song <baohua@kernel.org>,
Axel Rasmussen <axelrasmussen@google.com>,
Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
Baoquan He <baoquan.he@linux.dev>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Dev Jain <dev.jain@arm.com>, Usama Arif <usama.arif@linux.dev>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH v2 1/3] mm: page_alloc: add a watermark check that knows the migratetype
Date: Wed, 11 Nov 2026 19:49:25 +0000 [thread overview]
Message-ID: <avTEezDIsJBhsPmi@thinkstation> (raw)
In-Reply-To: <auynaZkzdzL6Aeyo@thinkstation>
On Thu, Nov 05, 2026 at 05:06:39PM +0000, Harry Yoo wrote:
> On Mon, Nov 02, 2026 at 09:39:34AM +0000, Kiryl Shutsemau (Meta) wrote:
> > The high-order check in __zone_watermark_ok() accepts a free page of any
> > migratetype. Under ALLOC_NOFRAGMENT, a request below pageblock_order can
> > only take a page of its own migratetype or claim a whole free block, so
> > the check can pass when the allocation cannot succeed.
> >
> > Telling those apart needs the request's migratetype, but not every check
> > wants them told apart. A check whether an allocation can be served now
> > has to count only the pages it can take.
> >
> > A check whether there is enough free memory counts every migratetype:
> > kswapd and kcompactd balancing a zone, order-0 thresholds, the
> > slowpath's forecast whether reclaim and compaction can still make
> > progress. Reclaim and compaction work across migratetypes to free whole
> > pageblocks.
>
> nit: perhaps we could make the changelog above bit more concise.
>
> I think the necessary bit here is "With defrag_mode, allocations cannot
> steal a page from pageblocks of other migrate type, thus
> __zone_watermark_ok() needs to take that into account."
It is ALLOC_NOFRAGMENT, not defrag_mode: Normal zone allocations get it
on the first attempt when DMA32 is populated, with defrag_mode off. And
such an allocation can still claim a whole free pageblock of another
migratetype.
But fair, it can be shorter. A tighter version is below; it also says
why kcompactd passes MIGRATE_MOVABLE.
> nit: maybe let's set cc.migratetype and pass it?
The value is not read there: __zone_watermark_ok_mt() uses the
migratetype only under ALLOC_NOFRAGMENT, and kcompactd never passes it.
kcompactd_node_suitable() makes the same call and has no compact_control
to take it from.
Thanks for the review.
The new changelog:
The high-order check in __zone_watermark_ok() accepts a free page of any
migratetype. Under ALLOC_NOFRAGMENT, a request below pageblock_order can
only take a page of its own migratetype or claim a whole free block, so
the check can pass when the allocation cannot succeed.
Only a check whether one allocation can be served now should count just
the pages it can take. A check whether a zone has enough free memory
serves no single allocation and counts every migratetype: reclaim and
compaction free whole pageblocks across migratetypes.
Add __zone_watermark_ok_mt(), which takes the migratetype, for the first
kind:
- the allocator fast path, zone_watermark_fast();
- its recheck after node reclaim in get_page_from_freelist();
- compaction's up-front check, compaction_suit_allocation_order().
__zone_watermark_ok() wraps it for the second kind. kcompactd shares
compaction_suit_allocation_order() with direct compaction and passes
MIGRATE_MOVABLE, which is not read without ALLOC_NOFRAGMENT.
Declare both in mm/internal.h: nothing outside mm uses them.
Nothing reads the migratetype yet: no functional change. Preparation for
making the high-order check honour ALLOC_NOFRAGMENT.
Looks good?
--
Kiryl Shutsemau / Kirill A. Shutemov
next prev parent reply other threads:[~2026-11-11 19:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 9:39 [PATCH v2 0/3] mm: make watermark checks honour ALLOC_NOFRAGMENT Kiryl Shutsemau (Meta)
2026-11-02 9:39 ` [PATCH v2 1/3] mm: page_alloc: add a watermark check that knows the migratetype Kiryl Shutsemau (Meta)
2026-11-05 17:06 ` Harry Yoo
2026-11-11 19:49 ` Kiryl Shutsemau [this message]
2026-11-02 9:39 ` [PATCH v2 2/3] mm: page_alloc: make the high-order watermark check honour ALLOC_NOFRAGMENT Kiryl Shutsemau (Meta)
2026-11-02 9:39 ` [PATCH v2 3/3] mm: vmscan: tell direct reclaim the allocation is ALLOC_NOFRAGMENT Kiryl Shutsemau (Meta)
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=avTEezDIsJBhsPmi@thinkstation \
--to=kas@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=baoquan.he@linux.dev \
--cc=brendan.jackman@linux.dev \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=hannes@cmpxchg.org \
--cc=harry@kernel.org \
--cc=kasong@tencent.com \
--cc=kernel-team@meta.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=qi.zheng@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=weixugc@google.com \
--cc=yuanchu@google.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®