Subject: Re: [PATCH v2 7/7] mm/vmalloc: Stop scanning for compound pages after encountering small pages in vmap

From: Uladzislau Rezki <[email-masked]>
Date: Wed, 20 May 2026 11:44:24 +0200

On Thu, May 14, 2026 at 05:41:08PM +0800, Wen Jiang wrote:
> From: "Barry Song (Xiaomi)" <[email-masked]>
> 
> Users typically allocate memory in descending orders, e.g.
> 8 → 4 → 0. Once an order-0 page is encountered, subsequent
> pages are likely to also be order-0, so we stop scanning
> for compound pages at that point.
> 
> Signed-off-by: Barry Song (Xiaomi) <[email-masked]>
> Signed-off-by: Wen Jiang <[email-masked]>
> Tested-by: Xueyuan Chen <[email-masked]>
> ---
>  mm/vmalloc.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index b3389c8f1..60579bfbf 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -3576,6 +3576,12 @@ static int __vmap_huge(unsigned long addr, unsigned long end,
>  			map_addr = addr;
>  			idx = i;
>  		}
> +		/*
> +		 * Once small pages are encountered, the remaining pages
> +		 * are likely small as well
> +		 */
> +		if (shift == PAGE_SHIFT)
> +			break;
>  
>  		addr += 1UL << shift;
>  		i += 1U << (shift - PAGE_SHIFT);
> -- 
> 2.34.1
> 
Can we squash this patch with
"mm/vmalloc: map contiguous pages in batches for vmap() if possible"?

--
Uladzislau Rezki