[RFC v2 PATCH 16/17] mm: mmap: Align unhinted maps to highest anon folio order

Yin, Fengwei fengwei.yin at intel.com
Mon Apr 17 01:25:44 PDT 2023



On 4/14/2023 9:03 PM, Ryan Roberts wrote:
> When allocating large anonymous folios, we want to maximize our chances
> of being able to use the highest order we support. Since one of the
> constraints is that a folio has to be mapped naturally aligned, let's
> have mmap default to that alignment when user space does not provide a
> hint.
> 
> With this in place, an extra 2% of all allocated anonymous memory
> belongs to a folio of the highest order, when compiling the kernel.
This change has side effect: reduce the chance of VMA merging.
So benefit to per-VMA lock also. But find VMA need searching more VMAs.


Regards
Yin, Fengwei

> 
> Signed-off-by: Ryan Roberts <ryan.roberts at arm.com>
> ---
>  mm/mmap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index ff68a67a2a7c..e7652001a32e 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -1627,7 +1627,7 @@ generic_get_unmapped_area(struct file *filp, unsigned long addr,
>  	info.length = len;
>  	info.low_limit = mm->mmap_base;
>  	info.high_limit = mmap_end;
> -	info.align_mask = 0;
> +	info.align_mask = BIT(PAGE_SHIFT + ANON_FOLIO_ORDER_MAX) - 1;
>  	info.align_offset = 0;
>  	return vm_unmapped_area(&info);
>  }
> @@ -1677,7 +1677,7 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
>  	info.length = len;
>  	info.low_limit = max(PAGE_SIZE, mmap_min_addr);
>  	info.high_limit = arch_get_mmap_base(addr, mm->mmap_base);
> -	info.align_mask = 0;
> +	info.align_mask = BIT(PAGE_SHIFT + ANON_FOLIO_ORDER_MAX) - 1;
>  	info.align_offset = 0;
>  	addr = vm_unmapped_area(&info);
> 
> --
> 2.25.1
> 



More information about the linux-arm-kernel mailing list