lkml.org 
[lkml]   [2019]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RESEND [PATCH] 2/2] mm/mmap.c: unlink vma before rb_erase
Date
Current sequence to remove a vma is:

vma_rb_erase_ignore()
__vma_unlink_list()
vma_gap_update()

This may do some extra subtree_gap propagation due the vma is unlink
from list after rb_erase.

For example, we have a tree:

a
[0x9000, 0x10000]
/ \
b c
[0x8000, 0x9000] [0x10000, 0x11000]
/
d
[0x6000, 0x7000]

The gap for each node is:

a's gap = 0x6000
b's gap = 0x6000
c's gap = 0x0
d's gap = 0x6000

Now we want to remove node d. Since we don't unlink d from link when
doing rb_erase, b's gap would still be computed to 0x1000. This leads to
the vma_gap_update() after list unlink would recompute b and a's gap.

For this case, by unlink the list before rb_erase, we would have one
time less of vma_compute_subtree_gap.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
mm/mmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 672ad7dc6b3c..907939690a30 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -678,8 +678,8 @@ static __always_inline void __vma_unlink_common(struct mm_struct *mm,
struct vm_area_struct *vma,
struct vm_area_struct *ignore)
{
- vma_rb_erase_ignore(vma, &mm->mm_rb, ignore);
__vma_unlink_list(mm, vma);
+ vma_rb_erase_ignore(vma, &mm->mm_rb, ignore);
/* Kill the cache */
vmacache_invalidate(mm);
}
--
2.17.1
\
 
 \ /
  Last update: 2019-08-28 08:07    [W:2.713 / U:0.988 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site