]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
rmap: always use anon_vma root pointer
authorAndrea Arcangeli <aarcange@redhat.com>
Tue, 10 Aug 2010 00:19:09 +0000 (17:19 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 10 Aug 2010 03:44:58 +0000 (20:44 -0700)
Always use anon_vma->root pointer instead of anon_vma_chain.prev.

Also optimize the map-paths, if a mapping is already established no need
to overwrite it with root anon-vma list, we can keep the more finegrined
anon-vma and skip the overwrite: see the PageAnon check in !exclusive
case.  This is also the optimization that hidden the ksm bug as this tends
to make ksm_might_need_to_copy skip the copy, but only the proper fix to
ksm_might_need_to_copy guarantees not triggering the ksm bug unless ksm is
in use.  this is an optimization only...

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Rik van Riel <riel@redhat.com>
[kamezawa.hiroyu@jp.fujitsu.com: fix false positive BUG_ON in __page_set_anon_rmap]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/rmap.c

index dce74a9efdd672ac7d361fcf4ec6c0918c0a946f..f5d6799b8a744356873c4e20b67ee492b06c6dc3 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -767,14 +767,20 @@ static void __page_set_anon_rmap(struct page *page,
         * If the page isn't exclusively mapped into this vma,
         * we must use the _oldest_ possible anon_vma for the
         * page mapping!
-        *
-        * So take the last AVC chain entry in the vma, which is
-        * the deepest ancestor, and use the anon_vma from that.
         */
        if (!exclusive) {
-               struct anon_vma_chain *avc;
-               avc = list_entry(vma->anon_vma_chain.prev, struct anon_vma_chain, same_vma);
-               anon_vma = avc->anon_vma;
+               if (PageAnon(page))
+                       return;
+               anon_vma = anon_vma->root;
+       } else {
+               /*
+                * In this case, swapped-out-but-not-discarded swap-cache
+                * is remapped. So, no need to update page->mapping here.
+                * We convice anon_vma poitned by page->mapping is not obsolete
+                * because vma->anon_vma is necessary to be a family of it.
+                */
+               if (PageAnon(page))
+                       return;
        }
 
        anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;