The patch titled Subject: cpumask: use find_first_and_bit() has been added to the -mm tree. Its filename is cpumask-use-find_first_and_bit.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/cpumask-use-find_first_and_bit.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/cpumask-use-find_first_and_bit.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Yury Norov <yury.norov@xxxxxxxxx> Subject: cpumask: use find_first_and_bit() Now we have an efficient implementation for find_first_and_bit(), so switch cpumask to use it where appropriate. Link: https://lkml.kernel.org/r/20210814211713.180533-7-yury.norov@xxxxxxxxx Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx> Tested-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> Cc: Alexander Lobakin <alobakin@xxxxx> Cc: Alexey Klimov <aklimov@xxxxxxxxxx> Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> Cc: Dennis Zhou <dennis@xxxxxxxxxx> Cc: Jiri Olsa <jolsa@xxxxxxxxxx> Cc: kernel test robot <lkp@xxxxxxxxx> Cc: Ulf Hansson <ulf.hansson@xxxxxxxxxx> Cc: Will Deacon <will@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/cpumask.h | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) --- a/include/linux/cpumask.h~cpumask-use-find_first_and_bit +++ a/include/linux/cpumask.h @@ -123,6 +123,12 @@ static inline unsigned int cpumask_first return 0; } +static inline unsigned int cpumask_first_and(const struct cpumask *srcp1, + const struct cpumask *srcp2) +{ + return 0; +} + static inline unsigned int cpumask_last(const struct cpumask *srcp) { return 0; @@ -167,7 +173,7 @@ static inline unsigned int cpumask_local static inline int cpumask_any_and_distribute(const struct cpumask *src1p, const struct cpumask *src2p) { - return cpumask_next_and(-1, src1p, src2p); + return cpumask_first_and(src1p, src2p); } static inline int cpumask_any_distribute(const struct cpumask *srcp) @@ -196,6 +202,19 @@ static inline unsigned int cpumask_first } /** + * cpumask_first_and - return the first cpu from *srcp1 & *srcp2 + * @src1p: the first input + * @src2p: the second input + * + * Returns >= nr_cpu_ids if no cpus set in both. See also cpumask_next_and(). + */ +static inline +unsigned int cpumask_first_and(const struct cpumask *srcp1, const struct cpumask *srcp2) +{ + return find_first_and_bit(cpumask_bits(srcp1), cpumask_bits(srcp2), nr_cpumask_bits); +} + +/** * cpumask_last - get the last CPU in a cpumask * @srcp: - the cpumask pointer * @@ -586,15 +605,6 @@ static inline void cpumask_copy(struct c #define cpumask_any(srcp) cpumask_first(srcp) /** - * cpumask_first_and - return the first cpu from *srcp1 & *srcp2 - * @src1p: the first input - * @src2p: the second input - * - * Returns >= nr_cpu_ids if no cpus set in both. See also cpumask_next_and(). - */ -#define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p), (src2p)) - -/** * cpumask_any_and - pick a "random" cpu from *mask1 & *mask2 * @mask1: the first input cpumask * @mask2: the second input cpumask _ Patches currently in -mm which might be from yury.norov@xxxxxxxxx are bitops-protect-find_first_zero_bit-properly.patch bitops-move-find_bit__le-functions-from-leh-to-findh.patch include-move-findh-from-asm_generic-to-linux.patch arch-remove-generic_find_first_bit-entirely.patch lib-add-find_first_and_bit.patch cpumask-use-find_first_and_bit.patch all-replace-find_next_zero_bit-with-find_first_zero_bit-where-appropriate.patch tools-sync-tools-bitmap-with-mother-linux.patch cpumask-replace-cpumask_next_-with-cpumask_first_-where-appropriate.patch include-linux-move-for_each_bit-macros-from-bitopsh-to-findh.patch find-micro-optimize-for_each_setclear_bit.patch replace-for_each__bit_from-with-for_each__bit-where-appropriate.patch mm-percpu-micro-optimize-pcpu_is_populated.patch bitmap-unify-find_bit-operations.patch lib-bitmap-add-performance-test-for-bitmap_print_to_pagebuf.patch vsprintf-rework-bitmap_list_string.patch