]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
cpumask: introduce cpumask_nth_and_andnot
authorYury Norov <yury.norov@gmail.com>
Sat, 21 Jan 2023 04:24:29 +0000 (20:24 -0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 8 Feb 2023 02:20:00 +0000 (18:20 -0800)
Introduce cpumask_nth_and_andnot() based on find_nth_and_andnot_bit().
It's used in the following patch to traverse cpumasks without storing
intermediate result in temporary cpumask.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
Acked-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Peter Lafreniere <peter@n8pjl.ca>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/cpumask.h

index c2aa0aa26b457fd04ad56c3da030a9b788c77b50..7b16aede7ac5816787f91ccbaf88e6c696c1b3e4 100644 (file)
@@ -391,6 +391,26 @@ unsigned int cpumask_nth_andnot(unsigned int cpu, const struct cpumask *srcp1,
                                nr_cpumask_bits, cpumask_check(cpu));
 }
 
+/**
+ * cpumask_nth_and_andnot - get the Nth cpu set in 1st and 2nd cpumask, and clear in 3rd.
+ * @srcp1: the cpumask pointer
+ * @srcp2: the cpumask pointer
+ * @srcp3: the cpumask pointer
+ * @cpu: the N'th cpu to find, starting from 0
+ *
+ * Returns >= nr_cpu_ids if such cpu doesn't exist.
+ */
+static __always_inline
+unsigned int cpumask_nth_and_andnot(unsigned int cpu, const struct cpumask *srcp1,
+                                                       const struct cpumask *srcp2,
+                                                       const struct cpumask *srcp3)
+{
+       return find_nth_and_andnot_bit(cpumask_bits(srcp1),
+                                       cpumask_bits(srcp2),
+                                       cpumask_bits(srcp3),
+                                       nr_cpumask_bits, cpumask_check(cpu));
+}
+
 #define CPU_BITS_NONE                                          \
 {                                                              \
        [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL                  \