include/linux/nodemask.h: create next_node_in() helper
[linux-2.6-block.git] / mm / mempolicy.c
index 36cc01bc950a6e5f8ef94c0d0506f463e01791d9..8d369cee0cd68f7b640f48f63d1fdb5d7fc62dd1 100644 (file)
@@ -97,7 +97,6 @@
 
 #include <asm/tlbflush.h>
 #include <asm/uaccess.h>
-#include <linux/random.h>
 
 #include "internal.h"
 
@@ -347,9 +346,7 @@ static void mpol_rebind_nodemask(struct mempolicy *pol, const nodemask_t *nodes,
                BUG();
 
        if (!node_isset(current->il_next, tmp)) {
-               current->il_next = next_node(current->il_next, tmp);
-               if (current->il_next >= MAX_NUMNODES)
-                       current->il_next = first_node(tmp);
+               current->il_next = next_node_in(current->il_next, tmp);
                if (current->il_next >= MAX_NUMNODES)
                        current->il_next = numa_node_id();
        }
@@ -1709,9 +1706,7 @@ static unsigned interleave_nodes(struct mempolicy *policy)
        struct task_struct *me = current;
 
        nid = me->il_next;
-       next = next_node(nid, policy->v.nodes);
-       if (next >= MAX_NUMNODES)
-               next = first_node(policy->v.nodes);
+       next = next_node_in(nid, policy->v.nodes);
        if (next < MAX_NUMNODES)
                me->il_next = next;
        return nid;
@@ -1805,21 +1800,6 @@ static inline unsigned interleave_nid(struct mempolicy *pol,
                return interleave_nodes(pol);
 }
 
-/*
- * Return the bit number of a random bit set in the nodemask.
- * (returns NUMA_NO_NODE if nodemask is empty)
- */
-int node_random(const nodemask_t *maskp)
-{
-       int w, bit = NUMA_NO_NODE;
-
-       w = nodes_weight(*maskp);
-       if (w)
-               bit = bitmap_ord_to_pos(maskp->bits,
-                       get_random_int() % w, MAX_NUMNODES);
-       return bit;
-}
-
 #ifdef CONFIG_HUGETLBFS
 /*
  * huge_zonelist(@vma, @addr, @gfp_flags, @mpol)