lkml.org 
[lkml]   [2011]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: cpusets: randomize node rotor used in cpuset_mem_spread_node()
Date
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 959a8b8..8e57a72 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -93,6 +93,7 @@
>
> #include <asm/tlbflush.h>
> #include <asm/uaccess.h>
> +#include <linux/random.h>
>
> #include "internal.h"
>
> @@ -1649,6 +1650,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)

mempolicy.c is no best place for putting generic nodemask utility function.
but unforunately we have no alternative. Gack.
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>





\
 
 \ /
  Last update: 2011-04-14 04:21    [W:0.057 / U:0.608 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site