X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=mm%2Fmempolicy.c;h=8b57173c1dd5b09a8bb0b3e24fedb8c8584ce447;hb=8f57be8ee44d92ef161c5af685aedbb717db96e0;hp=e7fb9d25c54eb80a62a987fbfd5cb08c4ae8e055;hpb=86dd7909c2c4ae3f219a9233bf0f095b05632ecf;p=~andy%2Flinux diff --git a/mm/mempolicy.c b/mm/mempolicy.c index e7fb9d25c54..8b57173c1dd 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -93,6 +93,7 @@ #include #include +#include #include "internal.h" @@ -1645,6 +1646,21 @@ 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 -1 if nodemask is empty) + */ +int node_random(const nodemask_t *maskp) +{ + int w, bit = -1; + + 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)