Message ID | 20190826073106.29971-3-richardw.yang@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | mm/mmap.c: reduce subtree gap propagation a little | expand |
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); }
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(-)