Re: [PATCH v3 03/17] mm/mm_init: skip initializing shared vmemmap tail pages

From: Muchun Song

Date: Mon Aug 10 2026 - 23:40:59 EST




> On Aug 4, 2026, at 11:55, Muchun Song <songmuchun@xxxxxxxxxxxxx> wrote:
>
> memmap_init_range() initializes every struct page in the target range.
> For compound pages with vmemmap optimization, the tail struct pages are
> backed by a shared vmemmap page.
>
> Initializing those tail struct pages would overwrite the shared
> vmemmap page contents, requiring users such as HugeTLB to restore the
> metadata afterwards.
>
> Track the compound order for HVO-backed sections and use that metadata
> to detect struct pages that fall into the shared tail vmemmap range.
> Skip those shared tail pages in memmap_init_range(), then initialize
> pageblock migratetypes for the processed range with a helper after the
> per-page initialization loop.
>
> Keep direct mem_section access inside sparse helpers by exposing
> pfn_to_section_order() to users that only need the order associated with
> a PFN. This lets memmap_init_range() skip shared tail vmemmap pages
> without exposing __pfn_to_section() to !SPARSEMEM builds.
>
> This is a preparatory change for consolidating handling across users of
> vmemmap optimization, and it also avoids redundant initialization of
> shared tail vmemmap pages during early boot.
>
> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>

Sashiko said there is a missing assignment for the new order field in
struct mem_section. This is just an observation, not an issue, because
assignment is placed in patch 10. There's no extra action to take for
this report.

Thanks.