aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYury Norov <yury.norov@gmail.com>2024-01-28 22:21:04 -0800
committerPaolo Abeni <pabeni@redhat.com>2024-02-01 13:06:40 +0100
commitc1f5204efcbcced83f67f12fa8f1a7f5f244fb87 (patch)
tree4cf65b8c65041554ba6cdccd75ace4b62f247028 /lib
parent3723b56d6f73f7c8c3b521a80556f129830f6fb9 (diff)
downloadlinux-c1f5204efcbcced83f67f12fa8f1a7f5f244fb87.tar.gz
cpumask: add cpumask_weight_andnot()
Similarly to cpumask_weight_and(), cpumask_weight_andnot() is a handy helper that may help to avoid creating an intermediate mask just to calculate number of bits that set in a 1st given mask, and clear in 2nd one. Signed-off-by: Yury Norov <yury.norov@gmail.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/bitmap.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 09522af227f17e..b97692854966e0 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -348,6 +348,13 @@ unsigned int __bitmap_weight_and(const unsigned long *bitmap1,
}
EXPORT_SYMBOL(__bitmap_weight_and);
+unsigned int __bitmap_weight_andnot(const unsigned long *bitmap1,
+ const unsigned long *bitmap2, unsigned int bits)
+{
+ return BITMAP_WEIGHT(bitmap1[idx] & ~bitmap2[idx], bits);
+}
+EXPORT_SYMBOL(__bitmap_weight_andnot);
+
void __bitmap_set(unsigned long *map, unsigned int start, int len)
{
unsigned long *p = map + BIT_WORD(start);