Commit 012b1043 authored by Yury Norov [NVIDIA]'s avatar Yury Norov [NVIDIA] Committed by Yury Norov
Browse files

cpumask: introduce cpumask_random()



Propagate find_random_bit() to cpumask API.

CC: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatar"Yury Norov [NVIDIA]" <yury.norov@gmail.com>
parent c56f97c5
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -354,6 +354,18 @@ unsigned int cpumask_next_wrap(int n, const struct cpumask *src)
	return find_next_bit_wrap(cpumask_bits(src), small_cpumask_bits, n + 1);
}

/**
 * cpumask_random - get random cpu in *src.
 * @src: cpumask pointer
 *
 * Return: random set bit, or >= nr_cpu_ids if @src is empty.
 */
static __always_inline
unsigned int cpumask_random(const struct cpumask *src)
{
	return find_random_bit(cpumask_bits(src), nr_cpu_ids);
}

/**
 * for_each_cpu - iterate over every cpu in a mask
 * @cpu: the (optionally unsigned) integer iterator