ksm: mremap use err from ksm_madvise
authorHugh Dickins <[email protected]>
Tue, 22 Sep 2009 00:02:28 +0000 (17:02 -0700)
committerLinus Torvalds <[email protected]>
Tue, 22 Sep 2009 14:17:33 +0000 (07:17 -0700)
mremap move's use of ksm_madvise() was assuming -ENOMEM on failure,
because ksm_madvise used to say -EAGAIN for that; but ksm_madvise now says
-ENOMEM (letting madvise convert that to -EAGAIN), and can also say
-ERESTARTSYS when signalled: so pass the error from ksm_madvise.

Signed-off-by: Hugh Dickins <[email protected]>
Acked-by: Izik Eidus <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/mremap.c

index 93adddecf97858eb51f95e43835c8dfae1133194..20a07dba6be04fb20f21bbac5ed1e289a8ccd354 100644 (file)
@@ -175,6 +175,7 @@ static unsigned long move_vma(struct vm_area_struct *vma,
        unsigned long excess = 0;
        unsigned long hiwater_vm;
        int split = 0;
+       int err;
 
        /*
         * We'd prefer to avoid failure later on in do_munmap:
@@ -190,9 +191,10 @@ static unsigned long move_vma(struct vm_area_struct *vma,
         * pages recently unmapped.  But leave vma->vm_flags as it was,
         * so KSM can come around to merge on vma and new_vma afterwards.
         */
-       if (ksm_madvise(vma, old_addr, old_addr + old_len,
-                                               MADV_UNMERGEABLE, &vm_flags))
-               return -ENOMEM;
+       err = ksm_madvise(vma, old_addr, old_addr + old_len,
+                                               MADV_UNMERGEABLE, &vm_flags);
+       if (err)
+               return err;
 
        new_pgoff = vma->vm_pgoff + ((old_addr - vma->vm_start) >> PAGE_SHIFT);
        new_vma = copy_vma(&vma, new_addr, new_len, new_pgoff);