From: Matthew Wilcox <willy@infradead.org>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Matthew Wilcox <mawilcox@microsoft.com>
Subject: [PATCH 3/3] bitmap: Use memcmp optimisation in more situations
Date: Wed, 7 Jun 2017 07:29:24 -0700 [thread overview]
Message-ID: <20170607142924.28552-4-willy@infradead.org> (raw)
In-Reply-To: <20170607142924.28552-1-willy@infradead.org>
From: Matthew Wilcox <mawilcox@microsoft.com>
Commit 7dd968163f ("bitmap: bitmap_equal memcmp optimization") was
rather more restrictive than necessary; we can use memcmp() to implement
bitmap_equal() as long as the number of bits can be proved to be a
multiple of 8. And architectures other than s390 may be able to make
good use of this optimisation.
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
---
include/linux/bitmap.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 0b3e4452b054..26244e0098f0 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -266,10 +266,8 @@ static inline int bitmap_equal(const unsigned long *src1,
{
if (small_const_nbits(nbits))
return !((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits));
-#ifdef CONFIG_S390
- if (__builtin_constant_p(nbits) && (nbits % BITS_PER_LONG) == 0)
+ if (__builtin_constant_p(nbits & 7) && IS_ALIGNED(nbits, 8))
return !memcmp(src1, src2, nbits / 8);
-#endif
return __bitmap_equal(src1, src2, nbits);
}
--
2.11.0
next prev parent reply other threads:[~2017-06-07 14:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 14:29 [PATCH 0/3] Bitmap optimisations Matthew Wilcox
2017-06-07 14:29 ` [PATCH 1/3] bitmap: Optimise bitmap_set and bitmap_clear of a single bit Matthew Wilcox
2017-06-07 14:29 ` [PATCH 2/3] Turn bitmap_set and bitmap_clear into memset when possible Matthew Wilcox
2017-06-07 21:16 ` Rasmus Villemoes
2017-06-27 7:02 ` Matthew Wilcox
2017-06-27 7:58 ` Rasmus Villemoes
2017-06-07 14:29 ` Matthew Wilcox [this message]
2017-06-08 1:48 ` [PATCH 3/3] bitmap: Use memcmp optimisation in more situations Andy Shevchenko
2017-06-08 2:55 ` Matthew Wilcox
2017-06-08 12:31 ` Andy Shevchenko
2017-06-08 13:43 ` Rasmus Villemoes
2017-06-08 14:47 ` Andy Shevchenko
2017-06-07 21:37 ` [PATCH 0/3] Bitmap optimisations Rasmus Villemoes
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=20170607142924.28552-4-willy@infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mawilcox@microsoft.com \
--cc=schwidefsky@de.ibm.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).