Skip to content

Commit ca1250b

Browse files
norovtorvalds
authored andcommitted
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 <ynorov@caviumnetworks.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Matthew Wilcox <mawilcox@microsoft.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 0455c74 commit ca1250b

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

‎lib/bitmap.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,9 @@ EXPORT_SYMBOL(__bitmap_equal);
6464

6565
void __bitmap_complement(unsigned long *dst, const unsigned long *src, unsigned int bits)
6666
{
67-
unsigned int k, lim = bits/BITS_PER_LONG;
67+
unsigned int k, lim = BITS_TO_LONGS(bits);
6868
for (k = 0; k < lim; ++k)
6969
dst[k] = ~src[k];
70-
71-
if (bits % BITS_PER_LONG)
72-
dst[k] = ~src[k];
7370
}
7471
EXPORT_SYMBOL(__bitmap_complement);
7572

0 commit comments

Comments
 (0)