LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Yury Norov <ynorov@caviumnetworks.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Matthew Wilcox <mawilcox@microsoft.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-kernel@vger.kernel.org
Cc: Yury Norov <ynorov@caviumnetworks.com>
Subject: [PATCH] lib: micro-optimization for __bitmap_complement()
Date: Wed, 11 Apr 2018 17:59:14 +0300	[thread overview]
Message-ID: <20180411145914.6011-1-ynorov@caviumnetworks.com> (raw)

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.

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
 lib/bitmap.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lib/bitmap.c b/lib/bitmap.c
index c82c61b66e16..7adc10074cff 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -62,12 +62,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);
 
-- 
2.14.1

             reply	other threads:[~2018-04-11 14:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-11 14:59 Yury Norov [this message]
2018-04-20 13:43 ` Yury Norov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180411145914.6011-1-ynorov@caviumnetworks.com \
    --to=ynorov@caviumnetworks.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mawilcox@microsoft.com \
    --subject='Re: [PATCH] lib: micro-optimization for __bitmap_complement()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).