Re: [PATCH v2 03/11] mm/sparse-vmemmap: open-code init_compound_tail()

From: David Hildenbrand (Arm)

Date: Thu Sep 10 2026 - 03:53:31 EST


On 9/8/26 05:03, Muchun Song wrote:
> init_compound_tail() is only used by vmemmap_shared_tail_page(), where
> the shared tail page setup intentionally passes NULL as the compound head.
>
> Keeping this helper in mm/internal.h exposes that special case to the rest
> of the MM code and can make the NULL head argument look generally valid.
> Open-code the initialization at the only call site so the special-case use
> stays local to sparse vmemmap optimization.
>
> No functional change intended.
>
> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
> Acked-by: Qi Zheng <qi.zheng@xxxxxxxxx>
> ---
> v2:
> - Collect Acked-by from Qi Zheng
> ---
> mm/internal.h | 9 ---------
> mm/sparse-vmemmap.c | 5 ++++-
> 2 files changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/mm/internal.h b/mm/internal.h
> index da14c56fb24e..0dca33db068f 100644
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -786,15 +786,6 @@ static inline void prep_compound_tail(struct page *tail,
> VM_WARN_ON_ONCE(tail->private);
> }
>
> -static inline void init_compound_tail(struct page *tail,
> - const struct page *head, unsigned int order, struct zone *zone)
> -{
> - atomic_set(&tail->_mapcount, -1);
> - set_page_node(tail, zone_to_nid(zone));
> - set_page_zone(tail, zone_idx(zone));
> - prep_compound_tail(tail, head, order);
> -}
> -
> #if defined CONFIG_COMPACTION || defined CONFIG_CMA
>
> /*
> diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
> index 70143dd8b579..e453ce4675a0 100644
> --- a/mm/sparse-vmemmap.c
> +++ b/mm/sparse-vmemmap.c
> @@ -189,7 +189,10 @@ struct page __ref *vmemmap_shared_tail_page(unsigned int order, struct zone *zon
> for (int i = 0; i < PAGE_SIZE / sizeof(struct page); i++) {
> page = (struct page *)addr + i;
> mm_zero_struct_page(page);
> - init_compound_tail(page, NULL, order, zone);
> + atomic_set(&page->_mapcount, -1);
> + set_page_node(page, zone_to_nid(zone));
> + set_page_zone(page, zone_idx(zone));
> + prep_compound_tail(page, NULL, order);
> }
>
> page = virt_to_page(addr);

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

--
Cheers,

David