diff options
| author | Yury Norov [NVIDIA] <yury.norov@gmail.com> | 2025-06-19 14:26:24 -0400 |
|---|---|---|
| committer | Yury Norov <yury.norov@gmail.com> | 2025-07-08 19:11:57 -0400 |
| commit | 012b1043420c0bc62e52902499de40b66f37fd6a (patch) | |
| tree | d2f8f961cb994d8f0b085b93e3cb7a61aa0d62c5 | |
| parent | c56f97c5c71f17d781461d44acb777cd21521b81 (diff) | |
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>
| -rw-r--r-- | include/linux/cpumask.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 7ae80a7ca81e..39b71b662da3 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -355,6 +355,18 @@ unsigned int cpumask_next_wrap(int n, const struct cpumask *src) } /** + * 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 * @mask: the cpumask pointer |
