[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190828060614.19535-3-richardw.yang@linux.intel.com>
Date: Wed, 28 Aug 2019 14:06:14 +0800
From: Wei Yang <richardw.yang@...ux.intel.com>
To: akpm@...ux-foundation.org, vbabka@...e.cz,
kirill.shutemov@...ux.intel.com, yang.shi@...ux.alibaba.com
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Wei Yang <richardw.yang@...ux.intel.com>
Subject: [RESEND [PATCH] 2/2] mm/mmap.c: unlink vma before rb_erase
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@...ux.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
Powered by blists - more mailing lists