Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cpumask: re-introduce cpumask_next{,_and}_wrap()

cpumask_next_wrap_old() has two additional parameters, comparing to its
generic counterpart find_next_bit_wrap(). The reason for that is
historical.

Before 4fe49b3b97c262 ("lib/bitmap: introduce for_each_set_bit_wrap()
macro"), cpumask_next_wrap() was used to implement for_each_cpu_wrap()
iterator. Now that the iterator is an alias to generic
for_each_set_bit_wrap(), the additional parameters aren't used and may
confuse readers.

All existing users call cpumask_next_wrap() in a way that makes it
possible to turn it to straight and simple alias to find_next_bit_wrap().

In a couple of places kernel users opencode missing cpumask_next_and_wrap().
Add it as well.

CC: Alexander Gordeev <agordeev@linux.ibm.com>
CC: Bjorn Helgaas <helgaas@kernel.org>
Signed-off-by: Yury Norov <yury.norov@gmail.com>

+38
+38
include/linux/cpumask.h
··· 285 285 } 286 286 287 287 /** 288 + * cpumask_next_and_wrap - get the next cpu in *src1p & *src2p, starting from 289 + * @n+1. If nothing found, wrap around and start from 290 + * the beginning 291 + * @n: the cpu prior to the place to search (i.e. search starts from @n+1) 292 + * @src1p: the first cpumask pointer 293 + * @src2p: the second cpumask pointer 294 + * 295 + * Return: next set bit, wrapped if needed, or >= nr_cpu_ids if @src1p & @src2p is empty. 296 + */ 297 + static __always_inline 298 + unsigned int cpumask_next_and_wrap(int n, const struct cpumask *src1p, 299 + const struct cpumask *src2p) 300 + { 301 + /* -1 is a legal arg here. */ 302 + if (n != -1) 303 + cpumask_check(n); 304 + return find_next_and_bit_wrap(cpumask_bits(src1p), cpumask_bits(src2p), 305 + small_cpumask_bits, n + 1); 306 + } 307 + 308 + /** 309 + * cpumask_next_wrap - get the next cpu in *src, starting from @n+1. If nothing 310 + * found, wrap around and start from the beginning 311 + * @n: the cpu prior to the place to search (i.e. search starts from @n+1) 312 + * @src: cpumask pointer 313 + * 314 + * Return: next set bit, wrapped if needed, or >= nr_cpu_ids if @src is empty. 315 + */ 316 + static __always_inline 317 + unsigned int cpumask_next_wrap(int n, const struct cpumask *src) 318 + { 319 + /* -1 is a legal arg here. */ 320 + if (n != -1) 321 + cpumask_check(n); 322 + return find_next_bit_wrap(cpumask_bits(src), small_cpumask_bits, n + 1); 323 + } 324 + 325 + /** 288 326 * for_each_cpu - iterate over every cpu in a mask 289 327 * @cpu: the (optionally unsigned) integer iterator 290 328 * @mask: the cpumask pointer