[PATCH v4 1/5] mm/sparse-vmemmap: Fix vmemmap accounting underflow

David Hildenbrand (Arm) david at kernel.org
Thu Apr 23 04:47:33 AEST 2026


On 4/22/26 10:14, Muchun Song 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
> 
> This ensures proper accounting in all code paths, including error
> handling and early section cases.
> 
> Fixes: c3576889d87b ("mm: fix accounting of memmap pages")
> Signed-off-by: Muchun Song <songmuchun at bytedance.com>
> Acked-by: Mike Rapoport (Microsoft) <rppt at kernel.org>
> Acked-by: Oscar Salvador <osalvador at suse.de>
> ---

Much clearer, thanks!

Acked-by: David Hildenbrand (Arm) <david at kernel.org>

-- 
Cheers,

David


More information about the Linuxppc-dev mailing list