aboutsummaryrefslogtreecommitdiffstats
path: root/mm/rmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/rmap.c')
-rw-r--r--mm/rmap.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/mm/rmap.c b/mm/rmap.c
index fcd593c9c997..4bad3267537a 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -182,7 +182,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
182{ 182{
183 struct anon_vma_chain *avc, *pavc; 183 struct anon_vma_chain *avc, *pavc;
184 184
185 list_for_each_entry(pavc, &src->anon_vma_chain, same_vma) { 185 list_for_each_entry_reverse(pavc, &src->anon_vma_chain, same_vma) {
186 avc = anon_vma_chain_alloc(); 186 avc = anon_vma_chain_alloc();
187 if (!avc) 187 if (!avc)
188 goto enomem_failure; 188 goto enomem_failure;
@@ -232,6 +232,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
232 out_error_free_anon_vma: 232 out_error_free_anon_vma:
233 anon_vma_free(anon_vma); 233 anon_vma_free(anon_vma);
234 out_error: 234 out_error:
235 unlink_anon_vmas(vma);
235 return -ENOMEM; 236 return -ENOMEM;
236} 237}
237 238
@@ -733,9 +734,20 @@ void page_move_anon_rmap(struct page *page,
733static void __page_set_anon_rmap(struct page *page, 734static void __page_set_anon_rmap(struct page *page,
734 struct vm_area_struct *vma, unsigned long address) 735 struct vm_area_struct *vma, unsigned long address)
735{ 736{
736 struct anon_vma *anon_vma = vma->anon_vma; 737 struct anon_vma_chain *avc;
738 struct anon_vma *anon_vma;
739
740 BUG_ON(!vma->anon_vma);
741
742 /*
743 * We must use the _oldest_ possible anon_vma for the page mapping!
744 *
745 * So take the last AVC chain entry in the vma, which is the deepest
746 * ancestor, and use the anon_vma from that.
747 */
748 avc = list_entry(vma->anon_vma_chain.prev, struct anon_vma_chain, same_vma);
749 anon_vma = avc->anon_vma;
737 750
738 BUG_ON(!anon_vma);
739 anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON; 751 anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON;
740 page->mapping = (struct address_space *) anon_vma; 752 page->mapping = (struct address_space *) anon_vma;
741 page->index = linear_page_index(vma, address); 753 page->index = linear_page_index(vma, address);