Re: acl trouble after upgrading ubuntu
[safe/jmp/linux-2.6] / mm / migrate.c
index 246dcb9..7dbcb22 100644 (file)
@@ -67,6 +67,8 @@ int putback_lru_pages(struct list_head *l)
 
        list_for_each_entry_safe(page, page2, l, lru) {
                list_del(&page->lru);
+               dec_zone_page_state(page, NR_ISOLATED_ANON +
+                               page_is_file_cache(page));
                putback_lru_page(page);
                count++;
        }
@@ -121,20 +123,6 @@ static void remove_migration_pte(struct vm_area_struct *vma,
        if (!is_migration_entry(entry) || migration_entry_to_page(entry) != old)
                goto out;
 
-       /*
-        * Yes, ignore the return value from a GFP_ATOMIC mem_cgroup_charge.
-        * Failure is not an option here: we're now expected to remove every
-        * migration pte, and will cause crashes otherwise.  Normally this
-        * is not an issue: mem_cgroup_prepare_migration bumped up the old
-        * page_cgroup count for safety, that's now attached to the new page,
-        * so this charge should just be another incrementation of the count,
-        * to keep in balance with rmap.c's mem_cgroup_uncharging.  But if
-        * there's been a force_empty, those reference counts may no longer
-        * be reliable, and this charge can actually fail: oh well, we don't
-        * make the situation any worse by proceeding as if it had succeeded.
-        */
-       mem_cgroup_charge_migrate_fixup(new, mm, GFP_ATOMIC);
-
        get_page(new);
        pte = pte_mkold(mk_pte(new, vma->vm_page_prot));
        if (is_write_migration_entry(entry))
@@ -161,7 +149,7 @@ out:
 static void remove_file_migration_ptes(struct page *old, struct page *new)
 {
        struct vm_area_struct *vma;
-       struct address_space *mapping = page_mapping(new);
+       struct address_space *mapping = new->mapping;
        struct prio_tree_iter iter;
        pgoff_t pgoff = new->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
 
@@ -264,7 +252,7 @@ out:
  * The number of remaining references must be:
  * 1 for anonymous pages without a mapping
  * 2 for pages with a mapping
- * 3 for pages with a mapping and PagePrivate set.
+ * 3 for pages with a mapping and PagePrivate/PagePrivate2 set.
  */
 static int migrate_page_move_mapping(struct address_space *mapping,
                struct page *newpage, struct page *page)
@@ -284,7 +272,7 @@ static int migrate_page_move_mapping(struct address_space *mapping,
        pslot = radix_tree_lookup_slot(&mapping->page_tree,
                                        page_index(page));
 
-       expected_count = 2 + !!PagePrivate(page);
+       expected_count = 2 + page_has_private(page);
        if (page_count(page) != expected_count ||
                        (struct page *)radix_tree_deref_slot(pslot) != page) {
                spin_unlock_irq(&mapping->tree_lock);
@@ -326,7 +314,10 @@ static int migrate_page_move_mapping(struct address_space *mapping,
         */
        __dec_zone_page_state(page, NR_FILE_PAGES);
        __inc_zone_page_state(newpage, NR_FILE_PAGES);
-
+       if (PageSwapBacked(page)) {
+               __dec_zone_page_state(page, NR_SHMEM);
+               __inc_zone_page_state(newpage, NR_SHMEM);
+       }
        spin_unlock_irq(&mapping->tree_lock);
 
        return 0;
@@ -378,9 +369,6 @@ static void migrate_page_copy(struct page *newpage, struct page *page)
        anon = PageAnon(page);
        page->mapping = NULL;
 
-       if (!anon) /* This page was removed from radix-tree. */
-               mem_cgroup_uncharge_cache_page(page);
-
        /*
         * If any waiters have accumulated on the new page then
         * wake them up.
@@ -403,7 +391,7 @@ EXPORT_SYMBOL(fail_migrate_page);
 
 /*
  * Common logic to directly migrate a single page suitable for
- * pages that do not use PagePrivate.
+ * pages that do not use PagePrivate/PagePrivate2.
  *
  * Pages are locked upon entry and exit.
  */
@@ -539,7 +527,7 @@ static int fallback_migrate_page(struct address_space *mapping,
         * Buffers may be managed in a filesystem specific way.
         * We must have no buffers or drop them.
         */
-       if (PagePrivate(page) &&
+       if (page_has_private(page) &&
            !try_to_release_page(page, GFP_KERNEL))
                return -EAGAIN;
 
@@ -614,6 +602,7 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
        struct page *newpage = get_new_page(page, private, &result);
        int rcu_locked = 0;
        int charge = 0;
+       struct mem_cgroup *mem = NULL;
 
        if (!newpage)
                return -ENOMEM;
@@ -623,24 +612,26 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
                goto move_newpage;
        }
 
-       charge = mem_cgroup_prepare_migration(page, newpage);
-       if (charge == -ENOMEM) {
-               rc = -ENOMEM;
-               goto move_newpage;
-       }
        /* prepare cgroup just returns 0 or -ENOMEM */
-       BUG_ON(charge);
-
        rc = -EAGAIN;
+
        if (!trylock_page(page)) {
                if (!force)
                        goto move_newpage;
                lock_page(page);
        }
 
+       /* charge against new page */
+       charge = mem_cgroup_prepare_migration(page, &mem);
+       if (charge == -ENOMEM) {
+               rc = -ENOMEM;
+               goto unlock;
+       }
+       BUG_ON(charge);
+
        if (PageWriteback(page)) {
                if (!force)
-                       goto unlock;
+                       goto uncharge;
                wait_on_page_writeback(page);
        }
        /*
@@ -669,7 +660,7 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
         * free the metadata, so the page can be freed.
         */
        if (!page->mapping) {
-               if (!PageAnon(page) && PagePrivate(page)) {
+               if (!PageAnon(page) && page_has_private(page)) {
                        /*
                         * Go direct to try_to_free_buffers() here because
                         * a) that's what try_to_release_page() would do anyway
@@ -678,13 +669,15 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
                         *    needs to be effective.
                         */
                        try_to_free_buffers(page);
+                       goto rcu_unlock;
                }
-               goto rcu_unlock;
+               goto skip_unmap;
        }
 
        /* Establish migration ptes or remove ptes */
-       try_to_unmap(page, 1);
+       try_to_unmap(page, TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS);
 
+skip_unmap:
        if (!page_mapped(page))
                rc = move_to_new_page(newpage, page);
 
@@ -693,7 +686,9 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
 rcu_unlock:
        if (rcu_locked)
                rcu_read_unlock();
-
+uncharge:
+       if (!charge)
+               mem_cgroup_end_migration(mem, page, newpage);
 unlock:
        unlock_page(page);
 
@@ -705,12 +700,12 @@ unlock:
                 * restored.
                 */
                list_del(&page->lru);
+               dec_zone_page_state(page, NR_ISOLATED_ANON +
+                               page_is_file_cache(page));
                putback_lru_page(page);
        }
 
 move_newpage:
-       if (!charge)
-               mem_cgroup_end_migration(newpage);
 
        /*
         * Move the new page to the LRU. If migration was not successful
@@ -751,6 +746,13 @@ int migrate_pages(struct list_head *from,
        struct page *page2;
        int swapwrite = current->flags & PF_SWAPWRITE;
        int rc;
+       unsigned long flags;
+
+       local_irq_save(flags);
+       list_for_each_entry(page, from, lru)
+               __inc_zone_page_state(page, NR_ISOLATED_ANON +
+                               page_is_file_cache(page));
+       local_irq_restore(flags);
 
        if (!swapwrite)
                current->flags |= PF_SWAPWRITE;
@@ -816,7 +818,7 @@ static struct page *new_page_node(struct page *p, unsigned long private,
 
        *result = &pm->status;
 
-       return alloc_pages_node(pm->node,
+       return alloc_pages_exact_node(pm->node,
                                GFP_HIGHUSER_MOVABLE | GFP_THISNODE, 0);
 }
 
@@ -834,7 +836,6 @@ static int do_move_page_to_node_array(struct mm_struct *mm,
        struct page_to_node *pp;
        LIST_HEAD(pagelist);
 
-       migrate_prep();
        down_read(&mm->mmap_sem);
 
        /*
@@ -921,6 +922,9 @@ static int do_pages_move(struct mm_struct *mm, struct task_struct *task,
        pm = (struct page_to_node *)__get_free_page(GFP_KERNEL);
        if (!pm)
                goto out;
+
+       migrate_prep();
+
        /*
         * Store a chunk of page_to_node array in a page,
         * but keep the last one as a marker
@@ -1069,10 +1073,10 @@ out:
  * Move a list of pages in the address space of the currently executing
  * process.
  */
-asmlinkage long sys_move_pages(pid_t pid, unsigned long nr_pages,
-                       const void __user * __user *pages,
-                       const int __user *nodes,
-                       int __user *status, int flags)
+SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
+               const void __user * __user *, pages,
+               const int __user *, nodes,
+               int __user *, status, int, flags)
 {
        const struct cred *cred = current_cred(), *tcred;
        struct task_struct *task;
@@ -1143,7 +1147,7 @@ int migrate_vmas(struct mm_struct *mm, const nodemask_t *to,
        struct vm_area_struct *vma;
        int err = 0;
 
-       for(vma = mm->mmap; vma->vm_next && !err; vma = vma->vm_next) {
+       for (vma = mm->mmap; vma && !err; vma = vma->vm_next) {
                if (vma->vm_ops && vma->vm_ops->migrate) {
                        err = vma->vm_ops->migrate(vma, to, from, flags);
                        if (err)