qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC] find_next_bit optimizations
@ 2013-03-11 13:44 Peter Lieven
  2013-03-11 14:04 ` Peter Maydell
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Peter Lieven @ 2013-03-11 13:44 UTC (permalink / raw)
  To: qemu-devel@nongnu.org; +Cc: Orit Wasserman, Corentin Chary, Paolo Bonzini

Hi,

I ever since had a few VMs which are very hard to migrate because of a lot of memory I/O. I found that finding the next dirty bit
seemed to be one of the culprits (apart from removing locking which Paolo is working on).

I have to following proposal which seems to help a lot in my case. Just wanted to have some feedback.
I applied the same unrolling idea like in buffer_is_zero().

Peter

--- a/util/bitops.c
+++ b/util/bitops.c
@@ -24,12 +24,13 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
      const unsigned long *p = addr + BITOP_WORD(offset);
      unsigned long result = offset & ~(BITS_PER_LONG-1);
      unsigned long tmp;
+    unsigned long d0,d1,d2,d3;

      if (offset >= size) {
          return size;
      }
      size -= result;
-    offset %= BITS_PER_LONG;
+    offset &= (BITS_PER_LONG-1);
      if (offset) {
          tmp = *(p++);
          tmp &= (~0UL << offset);
@@ -43,6 +44,18 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
          result += BITS_PER_LONG;
      }
      while (size & ~(BITS_PER_LONG-1)) {
+        while (!(size & (4*BITS_PER_LONG-1))) {
+            d0 = *p;
+            d1 = *(p+1);
+            d2 = *(p+2);
+            d3 = *(p+3);
+            if (d0 || d1 || d2 || d3) {
+                break;
+            }
+            p+=4;
+            result += 4*BITS_PER_LONG;
+            size -= 4*BITS_PER_LONG;
+        }
          if ((tmp = *(p++))) {
              goto found_middle;
          }

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2013-03-12 15:12 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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                   ` [Qemu-devel] [PATCH] bitops: unroll while loop in find_next_bit() Peter Lieven
2013-03-11 15:37         ` [Qemu-devel] [RFC] find_next_bit optimizations 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

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).