Re: [PATCH 1/5] mm: Deduplicate mm_get_unmapped_area()

From: David Laight
Date: Mon Jun 16 2025 - 04:01:48 EST


On Fri, 13 Jun 2025 09:41:07 -0400
Peter Xu <peterx@xxxxxxxxxx> wrote:

> Essentially it sets vm_flags==0 for mm_get_unmapped_area_vmflags(). Use
> the helper instead to dedup the lines.

Would it make more sense to make it an inline wrapper?
Moving the EXPORT_SYMBOL to mm_get_unmapped_area_vmflags.

David

>
> Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
> ---
> mm/mmap.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 09c563c95112..422f5b9d9660 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -871,9 +871,8 @@ mm_get_unmapped_area(struct mm_struct *mm, struct file *file,
> unsigned long addr, unsigned long len,
> unsigned long pgoff, unsigned long flags)
> {
> - if (test_bit(MMF_TOPDOWN, &mm->flags))
> - return arch_get_unmapped_area_topdown(file, addr, len, pgoff, flags, 0);
> - return arch_get_unmapped_area(file, addr, len, pgoff, flags, 0);
> + return mm_get_unmapped_area_vmflags(mm, file, addr, len,
> + pgoff, flags, 0);
> }
> EXPORT_SYMBOL(mm_get_unmapped_area);
>