Re: [PATCH 0/2] mm/page_alloc: fix lazy memory acceptance before watermarks are set

From: Kiryl Shutsemau (Meta)

Date: Thu Dec 03 2026 - 21:28:52 EST


On Mon, Nov 30, 2026 at 11:26:39AM -0600, Pankaj Gupta wrote:
> Lazy memory acceptance should accept memory only when it is needed.
> Since commit 800f1059c99e ("mm/page_alloc: fix memory accept before
> watermarks gets initialized"), one MAX_PAGE_ORDER page is accepted on
> every page allocation until the zone watermarks are set. On a 19 GiB
> SEV-SNP guest this accepts about ~14 GiB during boot and hence reduce the
> boot time.
>
> Patch 1 renames cond_accept_memory() to accept_memory_to_wmark().
>
> Patch 2 accepts memory before the watermarks are set only when an
> allocation cannot be satisfied.
>
> SEV-SNP guest with 19 GiB of memory, memory left unaccepted after boot,
> before and after this change:
>
> before after
> 4 vCPUs 3.1 GiB 14.7 GiB
> 64 vCPUs 2.8 GiB 13.9 GiB
>
> This also reduces the boot time of the guest.

Numbers looks iffy to me.

The table puts the difference at 11.6 GiB with 4 vCPUs. At 4 MiB per
allocation, that is about 3000 page allocations before
init_per_zone_wmark_min(). Where do they come from?

I traced kmem:mm_page_alloc from boot on a KVM guest. I see a few hundred
page allocations before init_per_zone_wmark_min() with 4 vCPUs and about
1,500 with 64. With deferred struct page init, most of ZONE_NORMAL only
reaches the unaccepted list in page_alloc_init_late(), and after that
there are 72 allocations with 4 vCPUs and 592 with 64. That is 0.3 GiB
and 2.3 GiB at most.

The number of early allocations also grows several times from 4 to 64
vCPUs, but your numbers barely move.

Could you show where the memory gets accepted? nr_unaccepted at the point
init_per_zone_wmark_min() runs, on both kernels, would tell how much of
the difference comes from this path.

--
Kiryl Shutsemau / Kirill A. Shutemov