From: Andrew Morton <akpm@linux-foundation.org>
To: Gonzalo Matias Juarez Tello <gmjuareztello@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/mmap.c: logic of find_vma_intersection repeated in __do_munmap
Date: Sun, 9 May 2021 22:08:34 -0700 [thread overview]
Message-ID: <20210509220834.d8b46dabea050d162df8cdf7@linux-foundation.org> (raw)
In-Reply-To: <20210409162129.18313-1-gmjuareztello@gmail.com>
On Fri, 9 Apr 2021 13:21:26 -0300 Gonzalo Matias Juarez Tello <gmjuareztello@gmail.com> wrote:
> Logic of find_vma_intersection() (which is an inline fc) is
> repeated in __do_munmap().
> Besides, prev is assigned a value before checking vma->vm_start >= end
> which might end up on a return statement making that assignment useless.
>
> Calling find_vma_intersection() checks that condition and returns NULL if
> no vma is found, hence only the !vma check is needed in __do_munmap().
>
> ...
>
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2822,16 +2822,11 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len,
> */
> arch_unmap(mm, start, end);
>
> - /* Find the first overlapping VMA */
> - vma = find_vma(mm, start);
> + /* Find the first overlapping VMA where start < vma->vm_end */
> + vma = find_vma_intersection(mm, start, end);
> if (!vma)
> return 0;
> prev = vma->vm_prev;
> - /* we have start < vma->vm_end */
> -
> - /* if it doesn't overlap, we have nothing.. */
> - if (vma->vm_start >= end)
> - return 0;
>
> /*
> * If we need to split any vma, do it now to save pain later.
Looks good to me, thanks.
prev parent reply other threads:[~2021-05-10 5:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-09 16:21 [PATCH] mm/mmap.c: logic of find_vma_intersection repeated in __do_munmap Gonzalo Matias Juarez Tello
2021-05-10 5:08 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210509220834.d8b46dabea050d162df8cdf7@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=gmjuareztello@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).