[PATCH v10 13/69] mm/mmap: use maple tree for unmapped_area{_topdown}

David Hildenbrand david at redhat.com
Thu Jun 23 10:25:53 PDT 2022


On 21.06.22 22:46, Liam Howlett wrote:
> From: "Liam R. Howlett" <Liam.Howlett at Oracle.com>
> 
> The maple tree code was added to find the unmapped area in a previous
> commit and was checked against what the rbtree returned, but the actual
> result was never used.  Start using the maple tree implementation and
> remove the rbtree code.
> 
> Add kernel documentation comment for these functions.
> 
> Link: https://lkml.kernel.org/r/20220504010716.661115-15-Liam.Howlett@oracle.com
> Signed-off-by: Liam R. Howlett <Liam.Howlett at Oracle.com>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: David Howells <dhowells at redhat.com>
> Cc: "Matthew Wilcox (Oracle)" <willy at infradead.org>
> Cc: SeongJae Park <sj at kernel.org>
> Cc: Vlastimil Babka <vbabka at suse.cz>
> Cc: Will Deacon <will at kernel.org>
> Cc: Davidlohr Bueso <dave at stgolabs.net>
> Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
> ---
>  mm/mmap.c | 253 +++++++-----------------------------------------------
>  1 file changed, 32 insertions(+), 221 deletions(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 08845a0317bf..b91d22329418 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2053,250 +2053,61 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
>  	return error;
>  }
>  
> +/* unmapped_area() Find an area between the low_limit and the high_limit with

/**
 * unmapped_area() - ...

> + * the correct alignment and offset, all from @info. Note: current->mm is used
> + * for the search.
> + *
> + * @info: The unmapped area information including the range (low_limit -
> + * hight_limit), the alignment offset and mask.
> + *
> + * Return: A memory address or -ENOMEM.
> + */
>  static unsigned long unmapped_area(struct vm_unmapped_area_info *info)
>  {

...

>  
> +/* unmapped_area_topdown() Find an area between the low_limit and the

\Dito

> + * high_limit with * the correct alignment and offset at the highest available
> + * address, all from * @info. Note: current->mm is used for the search.

I'm confused about the "*" in the text, but maybe I'm just tired :)

> + *
> + * @info: The unmapped area information including the range (low_limit -
> + * hight_limit), the alignment offset and mask.
> + *
> + * Return: A memory address or -ENOMEM.
> + */
>  static unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
>  {

[...]

> -found:
> -	/* We found a suitable gap. Clip it with the original high_limit. */
> -	if (gap_end > info->high_limit)
> -		gap_end = info->high_limit;
> -
> -found_highest:
> -	/* Compute highest gap address at the desired alignment */
> -	gap_end -= info->length;
> -	gap_end -= (gap_end - info->align_offset) & info->align_mask;
> -
> -	VM_BUG_ON(gap_end < info->low_limit);
> -	VM_BUG_ON(gap_end < gap_start);

Can we leave some of these in, please? (same applies to other function)

I keep getting confused by align_offset. vs align_mask. I *think* this
is correct, but some checks that we stay in limits and actually have
proper alignment would be reasonable.


-- 
Thanks,

David / dhildenb




More information about the maple-tree mailing list