From: Peter Lieven <pl@dlhnet.de>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: peter.maydell@linaro.org, Paolo Bonzini <pbonzini@redhat.com>,
Corentin Chary <corentin.chary@gmail.com>,
ronnie sahlberg <ronniesahlberg@gmail.com>,
Orit Wasserman <owasserm@redhat.com>
Subject: [Qemu-devel] [PATCH] bitops: unroll while loop in find_next_bit().
Date: Tue, 12 Mar 2013 08:32:59 +0100 [thread overview]
Message-ID: <513EDA2B.5040608@dlhnet.de> (raw)
In-Reply-To: <513E0F4C.8080202@redhat.com>
this patch adopts the loop unrolling idea of bitmap_is_zero() to
speed up the skipping of large areas with zeros in find_next_bit().
this routine is extensively used to find dirty pages in
live migration.
testing only the find_next_bit performance on a zeroed bitfield
the loop onrolling decreased executing time by approx. 50% on x86_64.
Signed-off-by: Peter Lieven <pl@kamp.de>
---
util/bitops.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/util/bitops.c b/util/bitops.c
index e72237a..227c38b 100644
--- a/util/bitops.c
+++ b/util/bitops.c
@@ -42,7 +42,23 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
size -= BITS_PER_LONG;
result += BITS_PER_LONG;
}
- while (size & ~(BITS_PER_LONG-1)) {
+ while (size >= 4*BITS_PER_LONG) {
+ unsigned long d1, d2, d3;
+ tmp = *p;
+ d1 = *(p+1);
+ d2 = *(p+2);
+ d3 = *(p+3);
+ if (tmp) {
+ goto found_middle;
+ }
+ if (d1 | d2 | d3) {
+ break;
+ }
+ p += 4;
+ result += 4*BITS_PER_LONG;
+ size -= 4*BITS_PER_LONG;
+ }
+ while (size >= BITS_PER_LONG) {
if ((tmp = *(p++))) {
goto found_middle;
}
--
1.7.9.5
next prev parent reply other threads:[~2013-03-12 7:33 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-11 13:44 [Qemu-devel] [RFC] find_next_bit optimizations Peter Lieven
2013-03-11 14:04 ` Peter Maydell
2013-03-11 14:14 ` Paolo Bonzini
2013-03-11 14:22 ` Peter Lieven
2013-03-11 14:29 ` Peter Lieven
2013-03-11 14:35 ` Paolo Bonzini
2013-03-11 15:24 ` Peter Lieven
2013-03-11 15:25 ` Peter Maydell
2013-03-11 15:29 ` Paolo Bonzini
2013-03-11 15:37 ` Peter Lieven
2013-03-11 15:58 ` Paolo Bonzini
2013-03-11 17:06 ` ronnie sahlberg
2013-03-11 17:07 ` Paolo Bonzini
2013-03-11 18:20 ` Peter Lieven
2013-03-12 7:32 ` Peter Lieven [this message]
2013-03-11 15:37 ` Peter Maydell
2013-03-11 15:41 ` Peter Lieven
2013-03-11 15:42 ` Paolo Bonzini
2013-03-11 15:48 ` Peter Lieven
2013-03-12 8:35 ` Stefan Hajnoczi
2013-03-12 8:41 ` Peter Lieven
2013-03-12 15:12 ` Stefan Hajnoczi
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=513EDA2B.5040608@dlhnet.de \
--to=pl@dlhnet.de \
--cc=corentin.chary@gmail.com \
--cc=owasserm@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=ronniesahlberg@gmail.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).