mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 01:21:01 +07:00
0edaf86cf1
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. [mhocko@suse.com: use next_node_in() helper] Acked-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Michal Hocko <mhocko@kernel.org> Signed-off-by: Michal Hocko <mhocko@suse.com> Cc: Xishi Qiu <qiuxishi@huawei.com> Cc: Joonsoo Kim <js1304@gmail.com> Cc: David Rientjes <rientjes@google.com> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Laura Abbott <lauraa@codeaurora.org> Cc: Hui Zhu <zhuhui@xiaomi.com> Cc: Wang Xiaoqiang <wangxq10@lzu.edu.cn> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
31 lines
617 B
C
31 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
|