@@ -178,6 +178,19 @@ unsigned int cpumask_first_and(const struct cpumask *srcp1, const struct cpumask
178
178
return find_first_and_bit (cpumask_bits (srcp1 ), cpumask_bits (srcp2 ), small_cpumask_bits );
179
179
}
180
180
181
+ /**
182
+ * cpumask_first_andnot - return the first cpu from *srcp1 & ~*srcp2
183
+ * @srcp1: the first input
184
+ * @srcp2: the second input
185
+ *
186
+ * Return: >= nr_cpu_ids if no such cpu found.
187
+ */
188
+ static __always_inline
189
+ unsigned int cpumask_first_andnot (const struct cpumask * srcp1 , const struct cpumask * srcp2 )
190
+ {
191
+ return find_first_andnot_bit (cpumask_bits (srcp1 ), cpumask_bits (srcp2 ), small_cpumask_bits );
192
+ }
193
+
181
194
/**
182
195
* cpumask_first_and_and - return the first cpu from *srcp1 & *srcp2 & *srcp3
183
196
* @srcp1: the first input
@@ -284,6 +297,25 @@ unsigned int cpumask_next_and(int n, const struct cpumask *src1p,
284
297
small_cpumask_bits , n + 1 );
285
298
}
286
299
300
+ /**
301
+ * cpumask_next_andnot - get the next cpu in *src1p & ~*src2p
302
+ * @n: the cpu prior to the place to search (i.e. return will be > @n)
303
+ * @src1p: the first cpumask pointer
304
+ * @src2p: the second cpumask pointer
305
+ *
306
+ * Return: >= nr_cpu_ids if no further cpus set in both.
307
+ */
308
+ static __always_inline
309
+ unsigned int cpumask_next_andnot (int n , const struct cpumask * src1p ,
310
+ const struct cpumask * src2p )
311
+ {
312
+ /* -1 is a legal arg here. */
313
+ if (n != -1 )
314
+ cpumask_check (n );
315
+ return find_next_andnot_bit (cpumask_bits (src1p ), cpumask_bits (src2p ),
316
+ small_cpumask_bits , n + 1 );
317
+ }
318
+
287
319
/**
288
320
* cpumask_next_and_wrap - get the next cpu in *src1p & *src2p, starting from
289
321
* @n+1. If nothing found, wrap around and start from
@@ -458,6 +490,33 @@ unsigned int cpumask_any_and_but(const struct cpumask *mask1,
458
490
return cpumask_next_and (cpu , mask1 , mask2 );
459
491
}
460
492
493
+ /**
494
+ * cpumask_any_andnot_but - pick an arbitrary cpu from *mask1 & ~*mask2, but not this one.
495
+ * @mask1: the first input cpumask
496
+ * @mask2: the second input cpumask
497
+ * @cpu: the cpu to ignore
498
+ *
499
+ * If @cpu == -1, the function returns the first matching cpu.
500
+ * Returns >= nr_cpu_ids if no cpus set.
501
+ */
502
+ static __always_inline
503
+ unsigned int cpumask_any_andnot_but (const struct cpumask * mask1 ,
504
+ const struct cpumask * mask2 ,
505
+ int cpu )
506
+ {
507
+ unsigned int i ;
508
+
509
+ /* -1 is a legal arg here. */
510
+ if (cpu != -1 )
511
+ cpumask_check (cpu );
512
+
513
+ i = cpumask_first_andnot (mask1 , mask2 );
514
+ if (i != cpu )
515
+ return i ;
516
+
517
+ return cpumask_next_andnot (cpu , mask1 , mask2 );
518
+ }
519
+
461
520
/**
462
521
* cpumask_nth - get the Nth cpu in a cpumask
463
522
* @srcp: the cpumask pointer
0 commit comments