diff options
author | Andrea Arcangeli <aarcange@redhat.com> | 2010-08-09 20:19:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-09 23:44:58 -0400 |
commit | 288468c334e98aacbb7e2fb8bde6bc1adcd55e05 (patch) | |
tree | f64cfebd7fedfd4e53fd5d4474048d5475a339b9 /mm/rmap.c | |
parent | ba6f0ff3981e6263ab81ac512f04cca55b85ec81 (diff) |
rmap: always use anon_vma root pointer
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>
Diffstat (limited to 'mm/rmap.c')
-rw-r--r-- | mm/rmap.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -767,14 +767,20 @@ static void __page_set_anon_rmap(struct page *page, | |||
767 | * If the page isn't exclusively mapped into this vma, | 767 | * If the page isn't exclusively mapped into this vma, |
768 | * we must use the _oldest_ possible anon_vma for the | 768 | * we must use the _oldest_ possible anon_vma for the |
769 | * page mapping! | 769 | * page mapping! |
770 | * | ||
771 | * So take the last AVC chain entry in the vma, which is | ||
772 | * the deepest ancestor, and use the anon_vma from that. | ||
773 | */ | 770 | */ |
774 | if (!exclusive) { | 771 | if (!exclusive) { |
775 | struct anon_vma_chain *avc; | 772 | if (PageAnon(page)) |
776 | avc = list_entry(vma->anon_vma_chain.prev, struct anon_vma_chain, same_vma); | 773 | return; |
777 | anon_vma = avc->anon_vma; | 774 | anon_vma = anon_vma->root; |
775 | } else { | ||
776 | /* | ||
777 | * In this case, swapped-out-but-not-discarded swap-cache | ||
778 | * is remapped. So, no need to update page->mapping here. | ||
779 | * We convice anon_vma poitned by page->mapping is not obsolete | ||
780 | * because vma->anon_vma is necessary to be a family of it. | ||
781 | */ | ||
782 | if (PageAnon(page)) | ||
783 | return; | ||
778 | } | 784 | } |
779 | 785 | ||
780 | anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON; | 786 | anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON; |