diff options
Diffstat (limited to 'mm/mempolicy.c')
-rw-r--r-- | mm/mempolicy.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index e7fb9d25c54e..8b57173c1dd5 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -93,6 +93,7 @@ | |||
93 | 93 | ||
94 | #include <asm/tlbflush.h> | 94 | #include <asm/tlbflush.h> |
95 | #include <asm/uaccess.h> | 95 | #include <asm/uaccess.h> |
96 | #include <linux/random.h> | ||
96 | 97 | ||
97 | #include "internal.h" | 98 | #include "internal.h" |
98 | 99 | ||
@@ -1645,6 +1646,21 @@ static inline unsigned interleave_nid(struct mempolicy *pol, | |||
1645 | return interleave_nodes(pol); | 1646 | return interleave_nodes(pol); |
1646 | } | 1647 | } |
1647 | 1648 | ||
1649 | /* | ||
1650 | * Return the bit number of a random bit set in the nodemask. | ||
1651 | * (returns -1 if nodemask is empty) | ||
1652 | */ | ||
1653 | int node_random(const nodemask_t *maskp) | ||
1654 | { | ||
1655 | int w, bit = -1; | ||
1656 | |||
1657 | w = nodes_weight(*maskp); | ||
1658 | if (w) | ||
1659 | bit = bitmap_ord_to_pos(maskp->bits, | ||
1660 | get_random_int() % w, MAX_NUMNODES); | ||
1661 | return bit; | ||
1662 | } | ||
1663 | |||
1648 | #ifdef CONFIG_HUGETLBFS | 1664 | #ifdef CONFIG_HUGETLBFS |
1649 | /* | 1665 | /* |
1650 | * huge_zonelist(@vma, @addr, @gfp_flags, @mpol) | 1666 | * huge_zonelist(@vma, @addr, @gfp_flags, @mpol) |