]> git.hungrycats.org Git - linux/commitdiff
[PATCH] mpol in copy_vma
authorAndrew Morton <akpm@osdl.org>
Sat, 22 May 2004 15:03:56 +0000 (08:03 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 22 May 2004 15:03:56 +0000 (08:03 -0700)
From: Hugh Dickins <hugh@veritas.com>

I think Andi missed the copy_vma I recently added for mremap, and it'll
need something like below....  (Doesn't look like it'll optimize away when
it's not needed - rather bloaty.)

mm/mmap.c

index 0f66a034273d9b7b67970c68288bc584a4977078..cafc5fc389b44d904ea24d73185eeaf2e1df51bc 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1504,6 +1504,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
        struct mm_struct *mm = vma->vm_mm;
        struct vm_area_struct *new_vma, *prev;
        struct rb_node **rb_link, *rb_parent;
+       struct mempolicy *pol;
 
        find_vma_prepare(mm, addr, &prev, &rb_link, &rb_parent);
        new_vma = vma_merge(mm, prev, rb_parent, addr, addr + len,
@@ -1519,6 +1520,12 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
                new_vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
                if (new_vma) {
                        *new_vma = *vma;
+                       pol = mpol_copy(vma_policy(vma));
+                       if (IS_ERR(pol)) {
+                               kmem_cache_free(vm_area_cachep, new_vma);
+                               return NULL;
+                       }
+                       vma_set_policy(new_vma, pol);
                        INIT_LIST_HEAD(&new_vma->shared);
                        new_vma->vm_start = addr;
                        new_vma->vm_end = addr + len;