[PATCH v7 5/7] mm/vmalloc: Extract vm_shift() to consolidate mapping shift selection

Dev Jain dev.jain at arm.com
Mon Jul 20 00:50:48 PDT 2026



On 15/07/26 5:38 pm, Wen Jiang wrote:
> Extract the vmalloc mapping shift selection from
> __vmalloc_node_range_noprof() into vm_shift(), preparing for reuse by the
> vmap batching path.
> 
> No functional change.
> 
> Suggested-by: Dev Jain <dev.jain at arm.com>
> Signed-off-by: Wen Jiang <jiangwen6 at xiaomi.com>
> Tested-by: Xueyuan Chen <xueyuan.chen21 at gmail.com>
> Tested-by: Leo Yan <leo.yan at arm.com>
> ---

Reviewed-by: Dev Jain <dev.jain at arm.com>


>  mm/vmalloc.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index afc695d5973e8..a1e025120e9df 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -3549,6 +3549,14 @@ void vunmap(const void *addr)
>  }
>  EXPORT_SYMBOL(vunmap);
> 
> +static inline unsigned int vm_shift(pgprot_t prot, unsigned long size)
> +{
> +	if (arch_vmap_pmd_supported(prot) && size >= PMD_SIZE)
> +		return PMD_SHIFT;
> +
> +	return arch_vmap_pte_supported_shift(size);
> +}
> +
>  /**
>   * vmap - map an array of pages into virtually contiguous space
>   * @pages: array of page pointers
> @@ -4047,11 +4055,7 @@ void *__vmalloc_node_range_noprof(unsigned long size, unsigned long align,
>  		 * supporting them.
>  		 */
> 
> -		if (arch_vmap_pmd_supported(prot) && size >= PMD_SIZE)
> -			shift = PMD_SHIFT;
> -		else
> -			shift = arch_vmap_pte_supported_shift(size);
> -
> +		shift = vm_shift(prot, size);
>  		align = max(original_align, 1UL << shift);
>  	}
> 
> --
> 2.34.1
> 




More information about the linux-arm-kernel mailing list