]> err.no Git - linux-2.6/blobdiff - mm/migrate.c
Merge branch 'for_paulus' of master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc
[linux-2.6] / mm / migrate.c
index 033a12f4c9499657aa07b10860484757291cc0d0..3f1e0c2c942c90d59c565e92ee119479861f7c47 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/writeback.h>
 #include <linux/mempolicy.h>
 #include <linux/vmalloc.h>
+#include <linux/security.h>
 
 #include "internal.h"
 
@@ -615,15 +616,13 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
        /*
         * Establish migration ptes or remove ptes
         */
-       if (try_to_unmap(page, 1) != SWAP_FAIL) {
-               if (!page_mapped(page))
-                       rc = move_to_new_page(newpage, page);
-       } else
-               /* A vma has VM_LOCKED set -> permanent failure */
-               rc = -EPERM;
+       try_to_unmap(page, 1);
+       if (!page_mapped(page))
+               rc = move_to_new_page(newpage, page);
 
        if (rc)
                remove_migration_ptes(page, page);
+
 unlock:
        unlock_page(page);
 
@@ -905,6 +904,11 @@ asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages,
                goto out2;
        }
 
+       err = security_task_movememory(task);
+       if (err)
+               goto out2;
+
+
        task_nodes = cpuset_mems_allowed(task);
 
        /* Limit nr_pages so that the multiplication may not overflow */
@@ -970,3 +974,23 @@ out2:
 }
 #endif
 
+/*
+ * Call migration functions in the vma_ops that may prepare
+ * memory in a vm for migration. migration functions may perform
+ * the migration for vmas that do not have an underlying page struct.
+ */
+int migrate_vmas(struct mm_struct *mm, const nodemask_t *to,
+       const nodemask_t *from, unsigned long flags)
+{
+       struct vm_area_struct *vma;
+       int err = 0;
+
+       for(vma = mm->mmap; vma->vm_next && !err; vma = vma->vm_next) {
+               if (vma->vm_ops && vma->vm_ops->migrate) {
+                       err = vma->vm_ops->migrate(vma, to, from, flags);
+                       if (err)
+                               break;
+               }
+       }
+       return err;
+}