Received: from eggs.gnu.org ([2001:4830:134:3::10]:47592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGYGZ-00077E-8j for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:08:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGYGY-0002Ef-D7 for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:08:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59838) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dGYGY-0002Dt-6z for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:08:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 422A263336 for ; Thu, 1 Jun 2017 22:08:25 +0000 (UTC) From: Juan Quintela Date: Fri, 2 Jun 2017 00:08:10 +0200 Message-Id: <20170601220813.30535-3-quintela@redhat.com> In-Reply-To: <20170601220813.30535-1-quintela@redhat.com> References: <20170601220813.30535-1-quintela@redhat.com> Subject: [Qemu-devel] [PATCH 2/5] ram: Move ZERO_TARGET_PAGE inside XBZRLE List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: dgilbert@redhat.com, lvivier@redhat.com, peterx@redhat.com It was only used by XBZRLE anyways. Signed-off-by: Juan Quintela --- migration/ram.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index e503277..04b55a7 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -66,8 +66,6 @@ /* 0x80 is reserved in migration.h start with 0x100 next */ #define RAM_SAVE_FLAG_COMPRESS_PAGE 0x100 -static uint8_t *ZERO_TARGET_PAGE; - static inline bool is_zero_range(uint8_t *p, uint64_t size) { return buffer_is_zero(p, size); @@ -83,6 +81,8 @@ static struct { /* Cache for XBZRLE, Protected by lock. */ PageCache *cache; QemuMutex lock; + /* it will store a page full of zeros */ + uint8_t *zero_target_page; } XBZRLE; /* buffer used for XBZRLE decoding */ @@ -509,7 +509,7 @@ static void xbzrle_cache_zero_page(RAMState *rs, ram_addr_t current_addr) /* We don't care if this fails to allocate a new cache page * as long as it updated an old one */ - cache_insert(XBZRLE.cache, current_addr, ZERO_TARGET_PAGE, + cache_insert(XBZRLE.cache, current_addr, XBZRLE.zero_target_page, rs->bitmap_sync_count); } @@ -1453,10 +1453,11 @@ static void ram_migration_cleanup(void *opaque) cache_fini(XBZRLE.cache); g_free(XBZRLE.encoded_buf); g_free(XBZRLE.current_buf); - g_free(ZERO_TARGET_PAGE); + g_free(XBZRLE.zero_target_page); XBZRLE.cache = NULL; XBZRLE.encoded_buf = NULL; XBZRLE.current_buf = NULL; + XBZRLE.zero_target_page = NULL; } XBZRLE_cache_unlock(); migration_page_queue_free(rs); @@ -1877,7 +1878,7 @@ static int ram_state_init(RAMState *rs) if (migrate_use_xbzrle()) { XBZRLE_cache_lock(); - ZERO_TARGET_PAGE = g_malloc0(TARGET_PAGE_SIZE); + XBZRLE.zero_target_page = g_malloc0(TARGET_PAGE_SIZE); XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() / TARGET_PAGE_SIZE, TARGET_PAGE_SIZE); -- 2.9.4