rmap: always add new vmas at the end
authorAndrea Arcangeli <aarcange@redhat.com>
Tue, 10 Aug 2010 00:19:08 +0000 (17:19 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 10 Aug 2010 03:44:58 +0000 (20:44 -0700)
Make sure to always add new VMAs at the end of the list.  This is
important so rmap_walk does not miss a VMA that was created during the
rmap_walk.

The old code got this right most of the time due to luck, but was buggy
when anon_vma_prepare reused a mergeable anon_vma.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/rmap.c

index 07e9814c7a41ac92b92952059b6139a8ac5d3d90..dce74a9efdd672ac7d361fcf4ec6c0918c0a946f 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -147,7 +147,7 @@ int anon_vma_prepare(struct vm_area_struct *vma)
                        avc->anon_vma = anon_vma;
                        avc->vma = vma;
                        list_add(&avc->same_vma, &vma->anon_vma_chain);
-                       list_add(&avc->same_anon_vma, &anon_vma->head);
+                       list_add_tail(&avc->same_anon_vma, &anon_vma->head);
                        allocated = NULL;
                        avc = NULL;
                }