lib/nodemask: inline next_node_in() and node_random()
[linux-2.6-microblaze.git] / lib / nodemask.c
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/nodemask.h>
3 #include <linux/module.h>
4 #include <linux/random.h>
5
6 EXPORT_SYMBOL(__next_node_in);
7
8 #ifdef CONFIG_NUMA
9 /*
10  * Return the bit number of a random bit set in the nodemask.
11  * (returns NUMA_NO_NODE if nodemask is empty)
12  */
13 int node_random(const nodemask_t *maskp)
14 {
15         int w, bit = NUMA_NO_NODE;
16
17         w = nodes_weight(*maskp);
18         if (w)
19                 bit = bitmap_ord_to_pos(maskp->bits,
20                         get_random_int() % w, MAX_NUMNODES);
21         return bit;
22 }
23 #endif