Re: [PATCH v3 2/3] mm: page_alloc: make the high-order watermark check honour ALLOC_NOFRAGMENT

From: Dev Jain

Date: Mon Nov 23 2026 - 05:41:54 EST




On 19/11/26 7:32 pm, Kiryl Shutsemau (Meta) wrote:
> On Wed, Nov 18, 2026 at 01:40:17PM +0530, Dev Jain wrote:
>> So let us do something like: we have zone_watermark_ok_for_alloc. It will call
>> zone_watermark_ok, which will only handle the watermark computation (so this is a
>> refactor for the code ending at if (!order) line in current zone_watermark_ok).
>> Then it will also scan the freelists for the correct order, correct migratetype etc.

I think my wording was unclear. By "correct migratetype etc." I did not mean
"only the requested migratetype". I meant the same rules being enforced
below the if (!order) check in current __zone_watermark_ok(), in relation
to the migratetypes and orders while scanning the freelists.

>
> A count-only zone_watermark_ok() does not work for three callers that
> pass a high order: kswapd's pgdat_balanced(), kcompactd's
> __compact_finished() under defrag_mode, and should_reclaim_retry(). They
> ask whether the zone has a free page of that order regardless of
> migratetype. They need the free list scan without the migratetype
> filter, so neither of your two helpers fits them.
>
> So the split is not count vs scan. It is the zone as a whole vs one
> request, as the comment above __zone_watermark_ok() says. The _mt variant
> is the one that takes the request's migratetype. Callers that only want
> the count already pass order 0.

Although I thought a lot last week and my approach would cause more churn due
to changing lots of places to _for_alloc, so I am fine with your approach for
now. But read on.

Currently you pass migratetype and you say in the comment in patch 1:

"Use __zone_watermark_ok_mt() instead to check whether a particular allocation
can be served."

But, for the existing callers who pass order > 0 , aren't they also checking
whether the allocation can be served? It is confusing me that both alloc_flags
and migratetype are logically part of the "allocation context" but some
callers are doing alloc_flags & ~ALLOC_NOFRAGMENT ... I am not sure whether
the below Sashiko report is related to that, I didn't check in detail:

https://sashiko.dev/#/patchset/20261116125103.2894162-1-kas%40kernel.org



>
> I am not particularly tied to the _mt() name, but _for_alloc() is a
> mouthful.
>