Received: from eggs.gnu.org ([2001:4830:134:3::10]:58041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW59z-0001nh-Qa for qemu-devel@nongnu.org; Thu, 12 Mar 2015 11:36:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YW59v-0004W3-JA for qemu-devel@nongnu.org; Thu, 12 Mar 2015 11:36:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47851) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW59v-0004V6-Au for qemu-devel@nongnu.org; Thu, 12 Mar 2015 11:36:27 -0400 From: Juan Quintela In-Reply-To: (Liang Z. Li's message of "Thu, 26 Feb 2015 04:49:42 +0000") References: <1423778591-12590-1-git-send-email-quintela@redhat.com> <1423778591-12590-6-git-send-email-quintela@redhat.com> Date: Thu, 12 Mar 2015 16:36:23 +0100 Message-ID: <87y4n2p6rs.fsf@neno.neno> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 5/6] save_block_hdr: we can recalculate the cont parameter here Reply-To: quintela@redhat.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Li, Liang Z" Cc: Amit Shah , "qemu-devel@nongnu.org" "Li, Liang Z" wrote: >> -----Original Message----- >> From: Juan Quintela [mailto:quintela@redhat.com] >> Sent: Friday, February 13, 2015 6:03 AM >> To: qemu-devel@nongnu.org >> Cc: Li, Liang Z >> Subject: [PATCH 5/6] save_block_hdr: we can recalculate the cont parameter >> here >> >> No need to pass it through all the callers. Once there, update >> last_sent_block here. >> >> Signed-off-by: Juan Quintela >> --- >> arch_init.c | 47 ++++++++++++++++++++++++----------------------- >> 1 file changed, 24 insertions(+), 23 deletions(-) >> >> diff --git a/arch_init.c b/arch_init.c >> index 834f40c..95a61e2 100644 >> --- a/arch_init.c >> +++ b/arch_init.c >> @@ -304,34 +304,39 @@ uint64_t xbzrle_mig_pages_overflow(void) >> return acct_info.xbzrle_overflows; >> } >> >> +/* This is the last block that we have visited serching for dirty pages >> +*/ static RAMBlock *last_seen_block; >> +/* This is the last block from where we have sent data */ static >> +RAMBlock *last_sent_block; static ram_addr_t last_offset; static >> +unsigned long *migration_bitmap; static uint64_t migration_dirty_pages; >> +static uint32_t last_version; static bool ram_bulk_stage; >> + >> static size_t save_block_hdr(QEMUFile *f, RAMBlock *block, ram_addr_t >> offset, >> - int cont, int flag) >> + int flag) >> { >> size_t size; >> >> - qemu_put_be64(f, offset | cont | flag); >> + if (block == last_sent_block) { >> + offset |= RAM_SAVE_FLAG_CONTINUE; >> + } >> + >> + qemu_put_be64(f, offset | flag); >> size = 8; >> >> - if (!cont) { >> + if (block != last_sent_block) { >> qemu_put_byte(f, strlen(block->idstr)); >> qemu_put_buffer(f, (uint8_t *)block->idstr, >> strlen(block->idstr)); >> size += 1 + strlen(block->idstr); >> + last_sent_block = block; >> } >> return size; >> } > > If save_block_hdr function is changed to this, then in my patch, it > can't not be directly reused in > compression thread. A lock is needed to access last_sent_block. I > prefer the original implementation. ah ok, will redo this then. Thanks for the feedback. Later, Juan.