Skip to content

Commit

Permalink
lib/bitmap.c: micro-optimization for __bitmap_complement()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
norov authored and torvalds committed Jun 8, 2018
1 parent 0455c74 commit ca1250b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ca1250b

Please sign in to comment.