dirty page balancing: Get rid of broken unmapped_ratio logic
[safe/jmp/linux-2.6] / mm / mempolicy.c
index 0d70fb7..83c69f8 100644 (file)
@@ -78,6 +78,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/module.h>
+#include <linux/nsproxy.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/compat.h>
@@ -87,6 +88,7 @@
 #include <linux/migrate.h>
 #include <linux/rmap.h>
 #include <linux/security.h>
+#include <linux/syscalls.h>
 
 #include <asm/tlbflush.h>
 #include <asm/uaccess.h>
@@ -108,6 +110,9 @@ struct mempolicy default_policy = {
        .policy = MPOL_DEFAULT,
 };
 
+static void mpol_rebind_policy(struct mempolicy *pol,
+                               const nodemask_t *newmask);
+
 /* Do sanity checking on a policy */
 static int mpol_check_policy(int mode, nodemask_t *nodes)
 {
@@ -126,7 +131,7 @@ static int mpol_check_policy(int mode, nodemask_t *nodes)
                        return -EINVAL;
                break;
        }
-       return nodes_subset(*nodes, node_online_map) ? 0 : -EINVAL;
+       return nodes_subset(*nodes, node_states[N_HIGH_MEMORY]) ? 0 : -EINVAL;
 }
 
 /* Generate a custom zonelist for the BIND policy. */
@@ -459,7 +464,7 @@ static void mpol_set_task_struct_flag(void)
 }
 
 /* Set the process memory policy */
-long do_set_mempolicy(int mode, nodemask_t *nodes)
+static long do_set_mempolicy(int mode, nodemask_t *nodes)
 {
        struct mempolicy *new;
 
@@ -519,8 +524,8 @@ static int lookup_node(struct mm_struct *mm, unsigned long addr)
 }
 
 /* Retrieve NUMA policy */
-long do_get_mempolicy(int *policy, nodemask_t *nmask,
-                       unsigned long addr, unsigned long flags)
+static long do_get_mempolicy(int *policy, nodemask_t *nmask,
+                            unsigned long addr, unsigned long flags)
 {
        int err;
        struct mm_struct *mm = current->mm;
@@ -611,7 +616,8 @@ static struct page *new_node_page(struct page *page, unsigned long node, int **x
  * Migrate pages from one node to a target node.
  * Returns error or the number of pages not migrated.
  */
-int migrate_to_node(struct mm_struct *mm, int source, int dest, int flags)
+static int migrate_to_node(struct mm_struct *mm, int source, int dest,
+                          int flags)
 {
        nodemask_t nmask;
        LIST_HEAD(pagelist);
@@ -716,12 +722,29 @@ out:
 
 }
 
+/*
+ * Allocate a new page for page migration based on vma policy.
+ * Start assuming that page is mapped by vma pointed to by @private.
+ * Search forward from there, if not.  N.B., this assumes that the
+ * list of pages handed to migrate_pages()--which is how we get here--
+ * is in virtual address order.
+ */
 static struct page *new_vma_page(struct page *page, unsigned long private, int **x)
 {
        struct vm_area_struct *vma = (struct vm_area_struct *)private;
+       unsigned long uninitialized_var(address);
+
+       while (vma) {
+               address = page_address_in_vma(page, vma);
+               if (address != -EFAULT)
+                       break;
+               vma = vma->vm_next;
+       }
 
-       return alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma,
-                                       page_address_in_vma(page, vma));
+       /*
+        * if !vma, alloc_page_vma() will use task or system default policy
+        */
+       return alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);
 }
 #else
 
@@ -742,8 +765,9 @@ static struct page *new_vma_page(struct page *page, unsigned long private, int *
 }
 #endif
 
-long do_mbind(unsigned long start, unsigned long len,
-               unsigned long mode, nodemask_t *nmask, unsigned long flags)
+static long do_mbind(unsigned long start, unsigned long len,
+                    unsigned long mode, nodemask_t *nmask,
+                    unsigned long flags)
 {
        struct vm_area_struct *vma;
        struct mm_struct *mm = current->mm;
@@ -934,7 +958,7 @@ asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode,
 
        /* Find the mm_struct */
        read_lock(&tasklist_lock);
-       task = pid ? find_task_by_pid(pid) : current;
+       task = pid ? find_task_by_vpid(pid) : current;
        if (!task) {
                read_unlock(&tasklist_lock);
                return -ESRCH;
@@ -965,7 +989,7 @@ asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode,
                goto out;
        }
 
-       if (!nodes_subset(new, node_online_map)) {
+       if (!nodes_subset(new, node_states[N_HIGH_MEMORY])) {
                err = -EINVAL;
                goto out;
        }
@@ -988,7 +1012,8 @@ asmlinkage long sys_get_mempolicy(int __user *policy,
                                unsigned long maxnode,
                                unsigned long addr, unsigned long flags)
 {
-       int err, pval;
+       int err;
+       int uninitialized_var(pval);
        nodemask_t nodes;
 
        if (nmask != NULL && maxnode < MAX_NUMNODES)
@@ -1381,7 +1406,6 @@ EXPORT_SYMBOL(alloc_pages_current);
  * keeps mempolicies cpuset relative after its cpuset moves.  See
  * further kernel/cpuset.c update_nodemask().
  */
-void *cpuset_being_rebound;
 
 /* Slow path of a mempolicy copy */
 struct mempolicy *__mpol_copy(struct mempolicy *old)
@@ -1537,8 +1561,8 @@ static void sp_delete(struct shared_policy *sp, struct sp_node *n)
        kmem_cache_free(sn_cache, n);
 }
 
-struct sp_node *
-sp_alloc(unsigned long start, unsigned long end, struct mempolicy *pol)
+static struct sp_node *sp_alloc(unsigned long start, unsigned long end,
+                               struct mempolicy *pol)
 {
        struct sp_node *n = kmem_cache_alloc(sn_cache, GFP_KERNEL);
 
@@ -1716,7 +1740,8 @@ void numa_default_policy(void)
 }
 
 /* Migrate a policy to a different set of nodes */
-void mpol_rebind_policy(struct mempolicy *pol, const nodemask_t *newmask)
+static void mpol_rebind_policy(struct mempolicy *pol,
+                              const nodemask_t *newmask)
 {
        nodemask_t *mpolmask;
        nodemask_t tmp;
@@ -2011,4 +2036,3 @@ out:
                m->version = (vma != priv->tail_vma) ? vma->vm_start : 0;
        return 0;
 }
-