Re: [PATCH v2 1/6] mm/sparse-vmemmap: Fix vmemmap accounting underflow

Muchun Song
2026-04-15T11:27:58Z

> On Apr 15, 2026, at 19:14, Muchun Song <songmuchun@bytedance.com> wrote:
>
> In section_activate(), if populate_section_memmap() fails, the error
> handling path calls section_deactivate() to roll back the state. This
> causes a vmemmap accounting imbalance.
>
> Since commit c3576889d87b ("mm: fix accounting of memmap pages"),
> memmap pages are accounted for only after populate_section_memmap()
> succeeds. However, the failure path unconditionally calls
> section_deactivate(), which decreases the vmemmap count. Consequently,
> a failure in populate_section_memmap() leads to an accounting underflow,
> incorrectly reducing the system's tracked vmemmap usage.
>
> Fix this more thoroughly by moving all accounting calls into the lower
> level functions that actually perform the vmemmap allocation and freeing:
>
> - populate_section_memmap() accounts for newly allocated vmemmap pages
> - depopulate_section_memmap() unaccounts when vmemmap is freed
> - free_map_bootmem() handles early bootmem section accounting

Sorry, this line was forgotten to be deleted. The subsequent modification
of free_map_bootmem() is a separate cleanup.