]> git.baikalelectronics.ru Git - kernel.git/commit
lib/bitmap: add bitmap_weight_and()
authorYury Norov <yury.norov@gmail.com>
Sun, 18 Sep 2022 03:07:12 +0000 (20:07 -0700)
committerYury Norov <yury.norov@gmail.com>
Mon, 26 Sep 2022 19:19:12 +0000 (12:19 -0700)
commit297a264ed0e8166b5537a1273a5493b6d406adb0
tree13d0a9d2b34cc58777852bce8ed9732c3882e669
parent07a69fbc24ae34557f8d096f4c1ced9b2d0f9d92
lib/bitmap: add bitmap_weight_and()

The function calculates Hamming weight of (bitmap1 & bitmap2). Now we
have to do like this:
tmp = bitmap_alloc(nbits);
bitmap_and(tmp, map1, map2, nbits);
weight = bitmap_weight(tmp, nbits);
bitmap_free(tmp);

This requires additional memory, adds pressure on alloc subsystem, and
way less cache-friendly than just:
weight = bitmap_weight_and(map1, map2, nbits);

The following patches apply it for cpumask functions.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
include/linux/bitmap.h
include/linux/cpumask.h
lib/bitmap.c