]> err.no Git - linux-2.6/blobdiff - mm/mempolicy.c
Memoryless nodes: Update memory policy and page migration
[linux-2.6] / mm / mempolicy.c
index 3d6ac9505d0716e83c1eeee3a58ede5c5baa0a1b..0d70fb7d83becbeb7783293dff04c1f6c75ba595 100644 (file)
@@ -72,7 +72,6 @@
 #include <linux/hugetlb.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/mm.h>
 #include <linux/nodemask.h>
 #include <linux/cpuset.h>
 #include <linux/gfp.h>
@@ -82,7 +81,6 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/compat.h>
-#include <linux/mempolicy.h>
 #include <linux/swap.h>
 #include <linux/seq_file.h>
 #include <linux/proc_fs.h>
@@ -185,7 +183,9 @@ static struct mempolicy *mpol_new(int mode, nodemask_t *nodes)
        switch (mode) {
        case MPOL_INTERLEAVE:
                policy->v.nodes = *nodes;
-               if (nodes_weight(*nodes) == 0) {
+               nodes_and(policy->v.nodes, policy->v.nodes,
+                                       node_states[N_HIGH_MEMORY]);
+               if (nodes_weight(policy->v.nodes) == 0) {
                        kmem_cache_free(policy_cache, policy);
                        return ERR_PTR(-EINVAL);
                }
@@ -494,9 +494,9 @@ static void get_zonemask(struct mempolicy *p, nodemask_t *nodes)
                *nodes = p->v.nodes;
                break;
        case MPOL_PREFERRED:
-               /* or use current node instead of online map? */
+               /* or use current node instead of memory_map? */
                if (p->v.preferred_node < 0)
-                       *nodes = node_online_map;
+                       *nodes = node_states[N_HIGH_MEMORY];
                else
                        node_set(p->v.preferred_node, *nodes);
                break;
@@ -528,8 +528,18 @@ long do_get_mempolicy(int *policy, nodemask_t *nmask,
        struct mempolicy *pol = current->mempolicy;
 
        cpuset_update_task_memory_state();
-       if (flags & ~(unsigned long)(MPOL_F_NODE|MPOL_F_ADDR))
+       if (flags &
+               ~(unsigned long)(MPOL_F_NODE|MPOL_F_ADDR|MPOL_F_MEMS_ALLOWED))
                return -EINVAL;
+
+       if (flags & MPOL_F_MEMS_ALLOWED) {
+               if (flags & (MPOL_F_NODE|MPOL_F_ADDR))
+                       return -EINVAL;
+               *policy = 0;    /* just so it's initialized */
+               *nmask  = cpuset_current_mems_allowed;
+               return 0;
+       }
+
        if (flags & MPOL_F_ADDR) {
                down_read(&mm->mmap_sem);
                vma = find_vma_intersection(mm, addr, addr+1);
@@ -1677,7 +1687,7 @@ void __init numa_policy_init(void)
         * fall back to the largest node if they're all smaller.
         */
        nodes_clear(interleave_nodes);
-       for_each_online_node(nid) {
+       for_each_node_state(nid, N_HIGH_MEMORY) {
                unsigned long total_pages = node_present_pages(nid);
 
                /* Preserve the largest node */
@@ -1963,7 +1973,7 @@ int show_numa_map(struct seq_file *m, void *v)
                seq_printf(m, " huge");
        } else {
                check_pgd_range(vma, vma->vm_start, vma->vm_end,
-                               &node_online_map, MPOL_MF_STATS, md);
+                       &node_states[N_HIGH_MEMORY], MPOL_MF_STATS, md);
        }
 
        if (!md->pages)
@@ -1990,7 +2000,7 @@ int show_numa_map(struct seq_file *m, void *v)
        if (md->writeback)
                seq_printf(m," writeback=%lu", md->writeback);
 
-       for_each_online_node(n)
+       for_each_node_state(n, N_HIGH_MEMORY)
                if (md->node[n])
                        seq_printf(m, " N%d=%lu", n, md->node[n]);
 out: