On 9/27/26 04:54, Muchun Song wrote:
> HugeTLB and sparse-vmemmap each have their own helper to allocate the
> shared vmemmap tail page used by vmemmap optimization.
>
> Factor that logic into a common vmemmap_shared_tail_page() helper. It
> allocates the page through vmemmap_alloc_block(), initializes the tail
> struct pages, and uses cmpxchg() to install the per-zone shared page.
>
> This removes duplicate allocation logic while handling both early boot
> and runtime allocation through the same helper.
>
> Signed-off-by: Muchun Song <[email protected]>
> Acked-by: Qi Zheng <[email protected]>
> Acked-by: Mike Rapoport (Microsoft) <[email protected]>
> ---
> v5:
> - Move this patch before CONFIG_VMEMMAP_OPTIMIZATION is introduced
>
> v4:
> - Update the commit message for the renamed VMEMMAP_OPTIMIZATION config
> - Collect Acked-by from Mike Rapoport
>
> v2:
> - Collect Acked-by from Qi Zheng
> ---
[...]
>
> #ifdef CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP
> -static __meminit struct page *vmemmap_get_tail(unsigned int order, struct
> zone *zone)
> +struct page __ref *vmemmap_shared_tail_page(unsigned int order, struct zone
> *zone)
> {
> - struct page *p, *tail;
> - unsigned int idx;
> - int node = zone_to_nid(zone);
> + void *addr;
> + struct page *page;
> + const unsigned int idx = order - VMEMMAP_OPTIMIZATION_MIN_ORDER;
Nit: constants read much nicer all the way at the top.
Acked-by: David Hildenbrand (Arm) <[email protected]>
--
Cheers,
David