* [PATCH] mm/mmap.c: logic of find_vma_intersection repeated in __do_munmap
@ 2021-04-09 16:21 Gonzalo Matias Juarez Tello
2021-05-10 5:08 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Gonzalo Matias Juarez Tello @ 2021-04-09 16:21 UTC (permalink / raw)
To: linux-mm; +Cc: Gonzalo Matias Juarez Tello, Andrew Morton, linux-kernel
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().
Signed-off-by: Gonzalo Matias Juarez Tello <gmjuareztello@gmail.com>
---
mm/mmap.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index 3f287599a7a3..59ceaa474a00 100644
--- 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.
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/mmap.c: logic of find_vma_intersection repeated in __do_munmap
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
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2021-05-10 5:08 UTC (permalink / raw)
To: Gonzalo Matias Juarez Tello; +Cc: linux-mm, linux-kernel
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-10 5:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).