From patchwork Tue Aug 25 11:59:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Liang Z" X-Patchwork-Id: 510473 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A1B5A14012C for ; Tue, 25 Aug 2015 22:01:59 +1000 (AEST) Received: from localhost ([::1]:59578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUCvN-0000xP-Mo for incoming@patchwork.ozlabs.org; Tue, 25 Aug 2015 08:01:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUCtn-0006w0-5T for qemu-devel@nongnu.org; Tue, 25 Aug 2015 08:00:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUCtk-0006FQ-Dd for qemu-devel@nongnu.org; Tue, 25 Aug 2015 08:00:19 -0400 Received: from mga11.intel.com ([192.55.52.93]:23275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUCtk-0006E4-6g for qemu-devel@nongnu.org; Tue, 25 Aug 2015 08:00:16 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 25 Aug 2015 05:00:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,745,1432623600"; d="scan'208";a="775240535" Received: from ll.sh.intel.com (HELO localhost) ([10.239.13.27]) by fmsmga001.fm.intel.com with ESMTP; 25 Aug 2015 05:00:14 -0700 From: Liang Li To: qemu-devel@nongnu.org Date: Tue, 25 Aug 2015 19:59:10 +0800 Message-Id: <1440503950-14174-4-git-send-email-liang.z.li@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440503950-14174-1-git-send-email-liang.z.li@intel.com> References: <1440503950-14174-1-git-send-email-liang.z.li@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Cc: amit.shah@redhat.com, yang.z.zhang@intel.com, Liang Li , dgilbert@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 3/3] migration: optimization for one decompression thread X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When decompression thread count is set to 1, the current implementation is inefficient because of the following reason: 1. Thread syncronization cost; 2. Data copy; This patch optimizes the performance for the case of 1 decompress thread. In this case, the compression is done in process_incoming_migration_co, for some fast decompression algorithm, it can help to improve the performance. Signed-off-by: Liang Li --- migration/ram.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 0cc4f81..fc91997 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1414,6 +1414,9 @@ void migrate_decompress_threads_create(void) int i, thread_count; thread_count = migrate_decompress_threads(); + if (thread_count == 1) { + return; + } decompress_threads = g_new0(QemuThread, thread_count); decomp_param = g_new0(DecompressParam, thread_count); compressed_data_buf = g_malloc0(compressBound(TARGET_PAGE_SIZE)); @@ -1432,8 +1435,11 @@ void migrate_decompress_threads_join(void) { int i, thread_count; - quit_decomp_thread = true; thread_count = migrate_decompress_threads(); + if (thread_count == 1) { + return; + } + quit_decomp_thread = true; for (i = 0; i < thread_count; i++) { qemu_mutex_lock(&decomp_param[i].mutex); qemu_cond_signal(&decomp_param[i].cond); @@ -1575,7 +1581,14 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) break; } qemu_get_buffer(f, compressed_data_buf, len); - decompress_data_with_multi_threads(compressed_data_buf, host, len); + if (migrate_decompress_threads() == 1) { + unsigned long pagesize = TARGET_PAGE_SIZE; + uncompress((Bytef *)host, &pagesize, + (const Bytef *)compressed_data_buf, len); + } else { + decompress_data_with_multi_threads(compressed_data_buf, + host, len); + } break; case RAM_SAVE_FLAG_XBZRLE: host = host_from_stream_offset(f, addr, flags);