Skip to content

Commit 012b104

Browse files
committed
cpumask: introduce cpumask_random()
Propagate find_random_bit() to cpumask API. CC: Andrew Morton <[email protected]> Signed-off-by: "Yury Norov [NVIDIA]" <[email protected]>
1 parent c56f97c commit 012b104

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

include/linux/cpumask.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,18 @@ unsigned int cpumask_next_wrap(int n, const struct cpumask *src)
354354
return find_next_bit_wrap(cpumask_bits(src), small_cpumask_bits, n + 1);
355355
}
356356

357+
/**
358+
* cpumask_random - get random cpu in *src.
359+
* @src: cpumask pointer
360+
*
361+
* Return: random set bit, or >= nr_cpu_ids if @src is empty.
362+
*/
363+
static __always_inline
364+
unsigned int cpumask_random(const struct cpumask *src)
365+
{
366+
return find_random_bit(cpumask_bits(src), nr_cpu_ids);
367+
}
368+
357369
/**
358370
* for_each_cpu - iterate over every cpu in a mask
359371
* @cpu: the (optionally unsigned) integer iterator

0 commit comments

Comments
 (0)