@@ -337,6 +337,50 @@ unsigned int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
337337 return i ;
338338}
339339
340+ /**
341+ * cpumask_nth - get the first cpu in a cpumask
342+ * @srcp: the cpumask pointer
343+ * @cpu: the N'th cpu to find, starting from 0
344+ *
345+ * Returns >= nr_cpu_ids if such cpu doesn't exist.
346+ */
347+ static inline unsigned int cpumask_nth (unsigned int cpu , const struct cpumask * srcp )
348+ {
349+ return find_nth_bit (cpumask_bits (srcp ), nr_cpumask_bits , cpumask_check (cpu ));
350+ }
351+
352+ /**
353+ * cpumask_nth_and - get the first cpu in 2 cpumasks
354+ * @srcp1: the cpumask pointer
355+ * @srcp2: the cpumask pointer
356+ * @cpu: the N'th cpu to find, starting from 0
357+ *
358+ * Returns >= nr_cpu_ids if such cpu doesn't exist.
359+ */
360+ static inline
361+ unsigned int cpumask_nth_and (unsigned int cpu , const struct cpumask * srcp1 ,
362+ const struct cpumask * srcp2 )
363+ {
364+ return find_nth_and_bit (cpumask_bits (srcp1 ), cpumask_bits (srcp2 ),
365+ nr_cpumask_bits , cpumask_check (cpu ));
366+ }
367+
368+ /**
369+ * cpumask_nth_andnot - get the first cpu set in 1st cpumask, and clear in 2nd.
370+ * @srcp1: the cpumask pointer
371+ * @srcp2: the cpumask pointer
372+ * @cpu: the N'th cpu to find, starting from 0
373+ *
374+ * Returns >= nr_cpu_ids if such cpu doesn't exist.
375+ */
376+ static inline
377+ unsigned int cpumask_nth_andnot (unsigned int cpu , const struct cpumask * srcp1 ,
378+ const struct cpumask * srcp2 )
379+ {
380+ return find_nth_andnot_bit (cpumask_bits (srcp1 ), cpumask_bits (srcp2 ),
381+ nr_cpumask_bits , cpumask_check (cpu ));
382+ }
383+
340384#define CPU_BITS_NONE \
341385{ \
342386 [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \
0 commit comments