memcg: rework usage of stats by soft limit
[safe/jmp/linux-2.6] / mm / migrate.c
index 2a0ea3e..88000b8 100644 (file)
@@ -134,7 +134,7 @@ static int remove_migration_pte(struct page *new, struct vm_area_struct *vma,
                page_add_file_rmap(new);
 
        /* No need to invalidate - it was non-present before */
-       update_mmu_cache(vma, addr, pte);
+       update_mmu_cache(vma, addr, ptep);
 unlock:
        pte_unmap_unlock(ptep, ptl);
 out:
@@ -275,8 +275,6 @@ static int migrate_page_move_mapping(struct address_space *mapping,
  */
 static void migrate_page_copy(struct page *newpage, struct page *page)
 {
-       int anon;
-
        copy_highpage(newpage, page);
 
        if (PageError(page))
@@ -288,8 +286,8 @@ static void migrate_page_copy(struct page *newpage, struct page *page)
        if (TestClearPageActive(page)) {
                VM_BUG_ON(PageUnevictable(page));
                SetPageActive(newpage);
-       } else
-               unevictable_migrate_page(newpage, page);
+       } else if (TestClearPageUnevictable(page))
+               SetPageUnevictable(newpage);
        if (PageChecked(page))
                SetPageChecked(newpage);
        if (PageMappedToDisk(page))
@@ -313,8 +311,6 @@ static void migrate_page_copy(struct page *newpage, struct page *page)
        ClearPageSwapCache(page);
        ClearPagePrivate(page);
        set_page_private(page, 0);
-       /* page->mapping contains a flag for PageAnon() */
-       anon = PageAnon(page);
        page->mapping = NULL;
 
        /*
@@ -912,6 +908,9 @@ static int do_pages_move(struct mm_struct *mm, struct task_struct *task,
                                goto out_pm;
 
                        err = -ENODEV;
+                       if (node < 0 || node >= MAX_NUMNODES)
+                               goto out_pm;
+
                        if (!node_state(node, N_HIGH_MEMORY))
                                goto out_pm;
 
@@ -999,33 +998,27 @@ static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages,
 #define DO_PAGES_STAT_CHUNK_NR 16
        const void __user *chunk_pages[DO_PAGES_STAT_CHUNK_NR];
        int chunk_status[DO_PAGES_STAT_CHUNK_NR];
-       unsigned long i, chunk_nr = DO_PAGES_STAT_CHUNK_NR;
-       int err;
 
-       for (i = 0; i < nr_pages; i += chunk_nr) {
-               if (chunk_nr > nr_pages - i)
-                       chunk_nr = nr_pages - i;
+       while (nr_pages) {
+               unsigned long chunk_nr;
 
-               err = copy_from_user(chunk_pages, &pages[i],
-                                    chunk_nr * sizeof(*chunk_pages));
-               if (err) {
-                       err = -EFAULT;
-                       goto out;
-               }
+               chunk_nr = nr_pages;
+               if (chunk_nr > DO_PAGES_STAT_CHUNK_NR)
+                       chunk_nr = DO_PAGES_STAT_CHUNK_NR;
+
+               if (copy_from_user(chunk_pages, pages, chunk_nr * sizeof(*chunk_pages)))
+                       break;
 
                do_pages_stat_array(mm, chunk_nr, chunk_pages, chunk_status);
 
-               err = copy_to_user(&status[i], chunk_status,
-                                  chunk_nr * sizeof(*chunk_status));
-               if (err) {
-                       err = -EFAULT;
-                       goto out;
-               }
-       }
-       err = 0;
+               if (copy_to_user(status, chunk_status, chunk_nr * sizeof(*status)))
+                       break;
 
-out:
-       return err;
+               pages += chunk_nr;
+               status += chunk_nr;
+               nr_pages -= chunk_nr;
+       }
+       return nr_pages ? -EFAULT : 0;
 }
 
 /*