···17#include <linux/init.h>18#include <linux/bootmem.h>19#include <linux/module.h>20+#include <linux/random.h>21#include <asm/mmzone.h>22#include <asm/numa.h>23···4950 return (i < num_node_memblks) ? node_memblk[i].nid : (num_node_memblks ? -1 : 0);51}52+53+/*54+ * Return the bit number of a random bit set in the nodemask.55+ * (returns -1 if nodemask is empty)56+ */57+int __node_random(const nodemask_t *maskp)58+{59+ int w, bit = -1;60+61+ w = nodes_weight(*maskp);62+ if (w)63+ bit = bitmap_ord_to_pos(maskp->bits,64+ get_random_int() % w, MAX_NUMNODES);65+ return bit;66+}67+EXPORT_SYMBOL(__node_random);6869#if defined(CONFIG_SPARSEMEM) && defined(CONFIG_NUMA)70/*