Re: [PATCH v5 13/17] mm/sparse: remove section_map_size()

From: David Hildenbrand (Arm)

Date: Wed Sep 09 2026 - 06:34:15 EST


On 8/25/26 10:46, Muchun Song wrote:
> section_map_size() no longer provides any shared logic.
>
> After the sparse-vmemmap changes, its only remaining user is the
> !CONFIG_SPARSEMEM_VMEMMAP path in __populate_section_memmap(), which can
> compute the size inline with PAGE_ALIGN(sizeof(struct page) *
> PAGES_PER_SECTION).
>
> Remove section_map_size() and inline the remaining calculation.
>
> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
> Acked-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> ---
> v2:
> - Collect Acked-by from Mike Rapoport
> ---
> include/linux/mm.h | 1 -
> mm/sparse.c | 15 ++-------------
> 2 files changed, 2 insertions(+), 14 deletions(-)
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 441bd39eab73..b19711b6dbc6 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -5140,7 +5140,6 @@ static inline void print_vma_addr(char *prefix, unsigned long rip)
> }
> #endif
>
> -unsigned long section_map_size(void);
> struct page * __populate_section_memmap(unsigned long pfn,
> unsigned long nr_pages, int nid, struct vmem_altmap *altmap,
> struct dev_pagemap *pgmap);
> diff --git a/mm/sparse.c b/mm/sparse.c
> index 7096d8e13802..9349ed6326c0 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -209,23 +209,12 @@ void __init sparse_sections_init(void)
> memory_present(nid, start, end);
> }
>
> -#ifdef CONFIG_SPARSEMEM_VMEMMAP
> -unsigned long __init section_map_size(void)
> -{
> - return ALIGN(sizeof(struct page) * PAGES_PER_SECTION, PMD_SIZE);
> -}
> -
> -#else
> -unsigned long __init section_map_size(void)
> -{
> - return PAGE_ALIGN(sizeof(struct page) * PAGES_PER_SECTION);
> -}
> -
> +#ifndef CONFIG_SPARSEMEM_VMEMMAP
> struct page __init *__populate_section_memmap(unsigned long pfn,
> unsigned long nr_pages, int nid, struct vmem_altmap *altmap,
> struct dev_pagemap *pgmap)
> {
> - unsigned long size = section_map_size();
> + unsigned long size = PAGE_ALIGN(sizeof(struct page) * PAGES_PER_SECTION);

While at it, I'd make that const.

Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

--
Cheers,

David