From 5f252c3fd8ac8e06d7ce0e231e4bdbe0f4336159 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Thu, 19 Nov 2020 12:57:23 -0500 Subject: [PATCH] mm/mmap: Change __do_munmap() to avoid unnecessary lookups. As there is no longer a vmacache, find_vma() is more expensive and so avoid doing them Signed-off-by: Liam R. Howlett --- mm/mmap.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index f662afc944c7..ca0f9ea5e73e 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2720,7 +2720,6 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len, if (!vma) return 0; - prev = vma->vm_prev; /* we have start < vma->vm_end */ /* @@ -2744,16 +2743,24 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len, if (error) return error; prev = vma; + vma = vma_next(mm, prev); + } else { + prev = vma->vm_prev; } + if (vma->vm_end >= end) + last = vma; + else + last = find_vma_intersection(mm, end - 1, end); + /* Does it split the last one? */ - last = find_vma(mm, end); - if (last && end > last->vm_start) { + if (last && end < last->vm_end) { int error = __split_vma(mm, last, end, 1); if (error) return error; + vma = vma_next(mm, prev); } - vma = vma_next(mm, prev); + if (unlikely(uf)) { /* -- 2.50.1