From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UK3iH-000763-1d for qemu-devel@nongnu.org; Mon, 25 Mar 2013 05:29:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UK3iC-0007pM-AE for qemu-devel@nongnu.org; Mon, 25 Mar 2013 05:29:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35308) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UK3iC-0007pG-1N for qemu-devel@nongnu.org; Mon, 25 Mar 2013 05:29:04 -0400 Message-ID: <51501922.1020803@redhat.com> Date: Mon, 25 Mar 2013 11:30:10 +0200 From: Orit Wasserman MIME-Version: 1.0 References: <1363956370-23681-1-git-send-email-pl@kamp.de> <1363956370-23681-6-git-send-email-pl@kamp.de> In-Reply-To: <1363956370-23681-6-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv4 5/9] migration: search for zero instead of dup pages List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: Stefan Hajnoczi , Paolo Bonzini , qemu-devel@nongnu.org, quintela@redhat.com On 03/22/2013 02:46 PM, Peter Lieven wrote: > virtually all dup pages are zero pages. remove > the special is_dup_page() function and use the > optimized buffer_find_nonzero_offset() function > instead. > > here buffer_find_nonzero_offset() is used directly > to avoid the unnecssary additional checks in > buffer_is_zero(). > > raw performace gain checking zeroed memory > over is_dup_page() is approx. 15-20% with SSE2. > > Signed-off-by: Peter Lieven > --- > arch_init.c | 21 ++++++--------------- > 1 file changed, 6 insertions(+), 15 deletions(-) > > diff --git a/arch_init.c b/arch_init.c > index 1b71912..9ebca83 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -144,19 +144,10 @@ int qemu_read_default_config_files(bool userconfig) > return 0; > } > > -static int is_dup_page(uint8_t *page) > +static inline bool is_zero_page(uint8_t *p) > { > - 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; > + return buffer_find_nonzero_offset(p, TARGET_PAGE_SIZE) == > + TARGET_PAGE_SIZE; > } > > /* struct contains XBZRLE cache and a static page > @@ -443,12 +434,12 @@ 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 (is_zero_page(p)) { > acct_info.dup_pages++; > bytes_sent = save_block_hdr(f, block, offset, cont, > RAM_SAVE_FLAG_COMPRESS); > - qemu_put_byte(f, *p); > - bytes_sent += 1; > + qemu_put_byte(f, 0); > + bytes_sent++; > } else if (migrate_use_xbzrle()) { > current_addr = block->offset + offset; > bytes_sent = save_xbzrle_page(f, p, current_addr, block, > Reviewed-by: Orit Wasserman