[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCHv5 05/10] bitops: unroll while loop in find_next_bit(
From: |
Peter Lieven |
Subject: |
[Qemu-devel] [PATCHv5 05/10] bitops: unroll while loop in find_next_bit() |
Date: |
Tue, 26 Mar 2013 10:58:34 +0100 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCHv5 00/10] buffer_is_zero / migration optimizations, Peter Lieven, 2013/03/26
- [Qemu-devel] [PATCHv5 04/10] buffer_is_zero: use vector optimizations if possible, Peter Lieven, 2013/03/26
- [Qemu-devel] [PATCHv5 05/10] bitops: unroll while loop in find_next_bit(),
Peter Lieven <=
- [Qemu-devel] [PATCHv5 08/10] migration: do not sent zero pages in bulk stage, Peter Lieven, 2013/03/26
- [Qemu-devel] [PATCHv5 09/10] migration: do not search dirty pages in bulk stage, Peter Lieven, 2013/03/26
- [Qemu-devel] [PATCHv5 07/10] migration: add an indicator for bulk state of ram migration, Peter Lieven, 2013/03/26
- [Qemu-devel] [PATCHv5 06/10] migration: search for zero instead of dup pages, Peter Lieven, 2013/03/26
- [Qemu-devel] [PATCHv5 10/10] migration: use XBZRLE only after bulk stage, Peter Lieven, 2013/03/26
- [Qemu-devel] [PATCHv5 01/10] move vector definitions to qemu-common.h, Peter Lieven, 2013/03/26
- [Qemu-devel] [PATCHv5 02/10] add a zero splat vector to qemu-common.h, Peter Lieven, 2013/03/26