Patchwork [PATCHv2,5/9] migration: search for zero instead of dup pages

login
register
mail settings
Submitter Peter Lieven
Date March 15, 2013, 3:50 p.m.
Message ID <1363362619-3190-6-git-send-email-pl@kamp.de>
Download mbox | patch
Permalink /patch/228157/
State New
Headers show

Comments

Peter Lieven - March 15, 2013, 3:50 p.m.
virtually all dup pages are zero pages. remove
the speical is_dup_page() function and use the
optimized buffer_is_zero() function instead.

Signed-off-by: Peter Lieven <pl@kamp.de>
---
 arch_init.c |   17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
Eric Blake - March 19, 2013, 4:55 p.m.
On 03/15/2013 09:50 AM, Peter Lieven wrote:
> virtually all dup pages are zero pages. remove
> the speical is_dup_page() function and use the

s/speical/special/

> optimized buffer_is_zero() function instead.
> 
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
>  arch_init.c |   17 +----------------
>  1 file changed, 1 insertion(+), 16 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

Patch

diff --git a/arch_init.c b/arch_init.c
index 1b71912..87c16fc 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -144,21 +144,6 @@  int qemu_read_default_config_files(bool userconfig)
     return 0;
 }
 
-static int is_dup_page(uint8_t *page)
-{
-    VECTYPE *p = (VECTYPE *)page;
-    VECTYPE val = SPLAT(page);
-    int i;
-
-    for (i = 0; i < TARGET_PAGE_SIZE / sizeof(VECTYPE); i++) {
-        if (!ALL_EQ(val, p[i])) {
-            return 0;
-        }
-    }
-
-    return 1;
-}
-
 /* struct contains XBZRLE cache and a static page
    used by the compression */
 static struct {
@@ -443,7 +428,7 @@  static int ram_save_block(QEMUFile *f, bool last_stage)
 
             /* In doubt sent page as normal */
             bytes_sent = -1;
-            if (is_dup_page(p)) {
+            if (buffer_is_zero(p, TARGET_PAGE_SIZE)) {
                 acct_info.dup_pages++;
                 bytes_sent = save_block_hdr(f, block, offset, cont,
                                             RAM_SAVE_FLAG_COMPRESS);