Re: [PATCH v2 4/7] mm: extend the template fast path to zone-device compound tails

From: Mike Rapoport

Date: Sat May 23 2026 - 08:13:15 EST


On Thu, 21 May 2026 12:01:21 +0800, Li Zhe <lizhe.67@xxxxxxxxxxxxx> wrote:
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 2992711351a0..17a84d4cda01 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -1084,17 +1084,25 @@ static inline bool zone_device_page_init_optimization_enabled(void)
> IS_ALIGNED(sizeof(struct page), sizeof(u64));
> }
>
> -static inline void zone_device_template_page_init(struct page *template,
> - unsigned long pfn,
> - unsigned long zone_idx,
> - int nid,
> - struct dev_pagemap *pgmap)
> +static inline void zone_device_template_head_page_init(struct page *template,
> + unsigned long pfn, unsigned long zone_idx, int nid,
> + struct dev_pagemap *pgmap)

Yeah, two tabs from the start would be better :)

> @@ -1156,12 +1166,28 @@ static void __ref memmap_init_compound(struct page *head,
> [ ... skip 17 lines ... ]
> - zone_device_page_init_slow(page, pfn, zone_idx, nid, pgmap);
> - prep_compound_tail(page, head, order);
> - set_page_count(page, 0);
> + if (use_template) {
> + zone_device_page_init_from_template(page, pfn,
> + &template);

continue here and there won't be need to indent the slow path.

Reviewed-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>

--
Sincerely yours,
Mike.