From: Yury Norov Date: Fri, 8 Jun 2018 00:10:41 +0000 (-0700) Subject: lib/bitmap.c: micro-optimization for __bitmap_complement() X-Git-Tag: Ubuntu-5.2.0-15.16~4245^2~19 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=ca1250bbd4e0b852cafbc94d4d2610171107b252;p=mirror_ubuntu-eoan-kernel.git lib/bitmap.c: micro-optimization for __bitmap_complement() Use BITS_TO_LONGS() macro to avoid calculation of reminder (bits % BITS_PER_LONG) On ARM64 it saves 5 instruction for function - 16 before and 11 after. Link: http://lkml.kernel.org/r/20180411145914.6011-1-ynorov@caviumnetworks.com Signed-off-by: Yury Norov Reviewed-by: Andrew Morton Cc: Matthew Wilcox Cc: Rasmus Villemoes Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/lib/bitmap.c b/lib/bitmap.c index a42eff7e8c48..58f9750e49c6 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -64,12 +64,9 @@ EXPORT_SYMBOL(__bitmap_equal); void __bitmap_complement(unsigned long *dst, const unsigned long *src, unsigned int bits) { - unsigned int k, lim = bits/BITS_PER_LONG; + unsigned int k, lim = BITS_TO_LONGS(bits); for (k = 0; k < lim; ++k) dst[k] = ~src[k]; - - if (bits % BITS_PER_LONG) - dst[k] = ~src[k]; } EXPORT_SYMBOL(__bitmap_complement);