qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Mark Wu <wudxw@linux.vnet.ibm.com>
To: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 2/3] qed: add zero write detection support
Date: Thu, 08 Dec 2011 22:29:39 +0800	[thread overview]
Message-ID: <4EE0C9D3.4000201@linux.vnet.ibm.com> (raw)
In-Reply-To: <1323259859-8709-3-git-send-email-stefanha@linux.vnet.ibm.com>

I tried to optimize the zero detecting code with SSE instruction.   The 
idea comes from Paolo's patch "migration: vectorize is_dup_page".  It's 
expected to give us an noticeable improvement. But I didn't find any 
improvement in the qemu-io test even though I increased the image size 
to 5GB.  The following is my test patch.  Could you please review it to 
see if I made any mistake and SSE can help for zero detecting?

Thanks.


diff --git a/block/qed.c b/block/qed.c
index 75a44f3..61e4a27 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -998,6 +998,14 @@ static void qed_aio_write_l2_update_cb(void 
*opaque, int ret)
      qed_aio_write_l2_update(acb, ret, acb->cur_cluster);
  }

+#ifdef __SSE2__
+#include <emmintrin.h>
+#define VECTYPE        __m128i
+#define SPLAT(p)       _mm_set1_epi8(*(p))
+#define ALL_EQ(v1, v2) (_mm_movemask_epi8(_mm_cmpeq_epi8(v1, v2)) == 
0xFFFF)
+#define VECTYPE_ZERO   _mm_setzero_si128()
+#endif
+
  /**
   * Determine if we have a zero write to a block of clusters
   *
@@ -1027,6 +1035,19 @@ static bool qed_is_zero_write(QEDAIOCB *acb)
          }

          v = iov->iov_base;
+
+#ifdef __SSE2__
+       if ((iov->iov_len & 0x0f)) {
+            VECTYPE zero = VECTYPE_ZERO;
+            VECTYPE *p = (VECTYPE *)v;
+            for(j = 0; j < iov->iov_len / sizeof(VECTYPE); j++) {
+                 if (!ALL_EQ(p[j], zero)) {
+                    return false;
+                 }
+            }
+            continue;
+        }
+#endif
          for (j = 0; j < iov->iov_len; j += sizeof(v[0])) {
              if (v[j >> 3]) {
                  return false;

  reply	other threads:[~2011-12-08 14:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-07 12:10 [Qemu-devel] [PATCH v2 0/3] block: zero write detection Stefan Hajnoczi
2011-12-07 12:10 ` [Qemu-devel] [PATCH v2 1/3] block: add zero write detection interface Stefan Hajnoczi
2011-12-07 12:10 ` [Qemu-devel] [PATCH v2 2/3] qed: add zero write detection support Stefan Hajnoczi
2011-12-08 14:29   ` Mark Wu [this message]
2011-12-08 15:54     ` Stefan Hajnoczi
2011-12-07 12:10 ` [Qemu-devel] [PATCH v2 3/3] qemu-io: add zero write detection option 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=4EE0C9D3.4000201@linux.vnet.ibm.com \
    --to=wudxw@linux.vnet.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.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).