1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/nodemask.h>
3 #include <linux/module.h>
4 #include <linux/random.h>
6 EXPORT_SYMBOL(__next_node_in);
10 * Return the bit number of a random bit set in the nodemask.
11 * (returns NUMA_NO_NODE if nodemask is empty)
13 int node_random(const nodemask_t *maskp)
15 int w, bit = NUMA_NO_NODE;
17 w = nodes_weight(*maskp);
19 bit = bitmap_ord_to_pos(maskp->bits,
20 get_random_int() % w, MAX_NUMNODES);