Back to home page

LXR

 
 

    


0001 #include <linux/nodemask.h>
0002 #include <linux/module.h>
0003 #include <linux/random.h>
0004 
0005 int __next_node_in(int node, const nodemask_t *srcp)
0006 {
0007     int ret = __next_node(node, srcp);
0008 
0009     if (ret == MAX_NUMNODES)
0010         ret = __first_node(srcp);
0011     return ret;
0012 }
0013 EXPORT_SYMBOL(__next_node_in);
0014 
0015 #ifdef CONFIG_NUMA
0016 /*
0017  * Return the bit number of a random bit set in the nodemask.
0018  * (returns NUMA_NO_NODE if nodemask is empty)
0019  */
0020 int node_random(const nodemask_t *maskp)
0021 {
0022     int w, bit = NUMA_NO_NODE;
0023 
0024     w = nodes_weight(*maskp);
0025     if (w)
0026         bit = bitmap_ord_to_pos(maskp->bits,
0027             get_random_int() % w, MAX_NUMNODES);
0028     return bit;
0029 }
0030 #endif