mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-11-04 09:44:14 -05:00
Lots of code does node = next_node(node, XXX); if (node == MAX_NUMNODES) node = first_node(XXX); so create next_node_in() to do this and use it in various places. [[email protected]: use next_node_in() helper] Acked-by: Vlastimil Babka <[email protected]> Acked-by: Michal Hocko <[email protected]> Signed-off-by: Michal Hocko <[email protected]> Cc: Xishi Qiu <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: David Rientjes <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Laura Abbott <[email protected]> Cc: Hui Zhu <[email protected]> Cc: Wang Xiaoqiang <[email protected]> Cc: Johannes Weiner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
30 lines
617 B
C
30 lines
617 B
C
#include <linux/nodemask.h>
|
|
#include <linux/module.h>
|
|
#include <linux/random.h>
|
|
|
|
int __next_node_in(int node, const nodemask_t *srcp)
|
|
{
|
|
int ret = __next_node(node, srcp);
|
|
|
|
if (ret == MAX_NUMNODES)
|
|
ret = __first_node(srcp);
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(__next_node_in);
|
|
|
|
#ifdef CONFIG_NUMA
|
|
/*
|
|
* Return the bit number of a random bit set in the nodemask.
|
|
* (returns NUMA_NO_NODE if nodemask is empty)
|
|
*/
|
|
int node_random(const nodemask_t *maskp)
|
|
{
|
|
int w, bit = NUMA_NO_NODE;
|
|
|
|
w = nodes_weight(*maskp);
|
|
if (w)
|
|
bit = bitmap_ord_to_pos(maskp->bits,
|
|
get_random_int() % w, MAX_NUMNODES);
|
|
return bit;
|
|
}
|
|
#endif
|