From: sashiko-bot@kernel.org
To: "Pankaj Gupta" <pankaj.gupta@amd.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>
Cc: "Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>,
"Brendan Jackman" <brendan.jackman@linux.dev>,
"Zi Yan" <ziy@nvidia.com>, "Kiryl Shutsemau" <kas@kernel.org>,
"Tom Lendacky" <thomas.lendacky@amd.com>,
"Farrah Chen" <farrah.chen@intel.com>,
linux-mm@kvack.org, pankaj.gupta.linux@gmail.com
Subject: Re: [PATCH 2/2] mm/page_alloc: do not accept memory proactively before watermarks are set
Date: Tue, 01 Dec 2026 17:27:08 +0000 [thread overview]
Message-ID: <sashiko-outbox-243843@kernel.org> (raw)
In-Reply-To: <20261130172641.237214-3-pankaj.gupta@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm/page_alloc: broken unaccepted memory fallback in
alloc_pages_bulk_noprof()
--
commit 5ff45011bdd58457e1cacc254e4e75587e5fd4af
Author: Pankaj Gupta <pankaj.gupta@amd.com>
mm/page_alloc: do not accept memory proactively before watermarks are set
This commit makes accept_memory_to_wmark() return false while zone
watermarks are 0 and introduces accept_memory_for_alloc() to accept one
MAX_PAGE_ORDER page on watermark or allocation failure during early boot.
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index adba323ba8942..0ca638c0da462 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
[ ... ]
> @@ -5295,7 +5297,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
> break;
> }
>
> - if (accept_memory_to_wmark(zone, 0, alloc_flags))
> + if (accept_memory_for_alloc(zone, 0, alloc_flags))
> goto retry_this_zone;
>
> /* Try again if zone has deferred pages */
[Severity: Medium]
Does moving the early-boot acceptance fallback to
accept_memory_for_alloc() work in alloc_pages_bulk_noprof() before zone
watermarks are initialized?
Unaccepted pages are already counted in NR_FREE_PAGES by
__free_unaccepted() and are not subtracted by
__zone_watermark_unusable_free():
mm/page_alloc.c:zone_watermark_fast() {
free_pages = zone_page_state(z, NR_FREE_PAGES);
...
if (!order) {
long usable_free;
long reserved;
usable_free = free_pages;
reserved = __zone_watermark_unusable_free(z, 0, alloc_flags);
/* reserved may over estimate high-atomic reserves. */
usable_free -= min(usable_free, reserved);
if (usable_free > mark + z->lowmem_reserve[highest_zoneidx])
return true;
}
...
}
While promo_wmark_pages(zone) is 0, accept_memory_to_wmark() now does
nothing. If the zone's accepted free pages are exhausted while
NR_UNACCEPTED still exceeds mark + lowmem_reserve, zone_watermark_fast()
for order 0 passes and breaks out of the loop before reaching
accept_memory_for_alloc(). Because the __rmqueue_pcplist() loop below has
no accept_memory_for_alloc() fallback, alloc_pages_bulk_noprof() either
returns a partial bulk allocation or falls back to single-page allocation
at failed:.
Conversely, if zone_watermark_fast() fails (because total NR_FREE_PAGES
including NR_UNACCEPTED is below mark + lowmem_reserve),
try_to_accept_memory_one() in accept_memory_for_alloc() does not increase
NR_FREE_PAGES, so jumping to retry_this_zone loops and accepts every
unaccepted page in the zone without making zone_watermark_fast() pass.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130172641.237214-1-pankaj.gupta@amd.com?part=2
prev parent reply other threads:[~2026-12-01 17:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 17:26 [PATCH 0/2] mm/page_alloc: fix lazy memory acceptance before watermarks are set Pankaj Gupta
2026-11-30 17:26 ` [PATCH 1/2] mm/page_alloc: rename cond_accept_memory() to accept_memory_to_wmark() Pankaj Gupta
2026-11-30 17:26 ` [PATCH 2/2] mm/page_alloc: do not accept memory proactively before watermarks are set Pankaj Gupta
2026-12-01 17:27 ` sashiko-bot [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=sashiko-outbox-243843@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brendan.jackman@linux.dev \
--cc=farrah.chen@intel.com \
--cc=hannes@cmpxchg.org \
--cc=kas@kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=pankaj.gupta.linux@gmail.com \
--cc=pankaj.gupta@amd.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=surenb@google.com \
--cc=thomas.lendacky@amd.com \
--cc=vbabka@kernel.org \
--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