36d4b36b69
The functions are pretty thin wrappers around find_bit engine, and keeping them in c-file prevents compiler from small_const_nbits() optimization, which must take place for all systems with MAX_NUMNODES less than BITS_PER_LONG (default is 16 for me). Moving them to header file doesn't blow up the kernel size: add/remove: 1/2 grow/shrink: 9/5 up/down: 968/-88 (880) CC: Andy Shevchenko <andriy.shevchenko@linux.intel.com> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org> CC: Michael Ellerman <mpe@ellerman.id.au> CC: Paul Mackerras <paulus@samba.org> CC: Rasmus Villemoes <linux@rasmusvillemoes.dk> CC: Stephen Rothwell <sfr@canb.auug.org.au> CC: linuxppc-dev@lists.ozlabs.org Signed-off-by: Yury Norov <yury.norov@gmail.com>
24 lines
492 B
C
24 lines
492 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/nodemask.h>
|
|
#include <linux/module.h>
|
|
#include <linux/random.h>
|
|
|
|
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
|