mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 15:13:44 -04:00
cpumask: introduce cpumask_random()
Propagate find_random_bit() to cpumask API. CC: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: "Yury Norov [NVIDIA]" <yury.norov@gmail.com>
This commit is contained in:
committed by
Yury Norov
parent
c56f97c5c7
commit
012b104342
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user