From patchwork Wed Jun 3 08:08:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mao Zhongyi X-Patchwork-Id: 1302852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49cM9P4Z8Fz9sTH for ; Wed, 3 Jun 2020 18:13:13 +1000 (AEST) Received: from localhost ([::1]:54828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOWN-00068R-EH for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 04:13:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgOTV-00016H-VM for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:10:13 -0400 Received: from cmccmta1.chinamobile.com ([221.176.66.79]:7105) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOTU-0000Gy-Dn for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:10:13 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app04-12004 (RichMail) with SMTP id 2ee45ed75ab37ac-8b1fc; Wed, 03 Jun 2020 16:09:23 +0800 (CST) X-RM-TRANSID: 2ee45ed75ab37ac-8b1fc X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee85ed75aae43e-61014; Wed, 03 Jun 2020 16:09:23 +0800 (CST) X-RM-TRANSID: 2ee85ed75aae43e-61014 From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH 1/9] tests/migration: mem leak fix Date: Wed, 3 Jun 2020 16:08:56 +0800 Message-Id: <20200603080904.997083-2-maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> References: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> MIME-Version: 1.0 Received-SPF: pass client-ip=221.176.66.79; envelope-from=maozhongyi@cmss.chinamobile.com; helo=cmccmta1.chinamobile.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 04:09:40 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mao Zhongyi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" ‘data’ has the possibility of memory leaks, so use the glib macros g_autofree recommended by CODING_STYLE.rst to automatically release the memory that returned from g_malloc(). Signed-off-by: Mao Zhongyi Reviewed-by: Alex Bennée Reviewed-by: Laurent Vivier --- tests/migration/stress.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/tests/migration/stress.c b/tests/migration/stress.c index 0c23964693..f9626d50ee 100644 --- a/tests/migration/stress.c +++ b/tests/migration/stress.c @@ -170,26 +170,14 @@ static unsigned long long now(void) static int stressone(unsigned long long ramsizeMB) { size_t pagesPerMB = 1024 * 1024 / PAGE_SIZE; - char *ram = malloc(ramsizeMB * 1024 * 1024); + g_autofree char *ram = g_malloc(ramsizeMB * 1024 * 1024); char *ramptr; size_t i, j, k; - char *data = malloc(PAGE_SIZE); + g_autofree char *data = g_malloc(PAGE_SIZE); char *dataptr; size_t nMB = 0; unsigned long long before, after; - if (!ram) { - fprintf(stderr, "%s (%05d): ERROR: cannot allocate %llu MB of RAM: %s\n", - argv0, gettid(), ramsizeMB, strerror(errno)); - return -1; - } - if (!data) { - fprintf(stderr, "%s (%d): ERROR: cannot allocate %d bytes of RAM: %s\n", - argv0, gettid(), PAGE_SIZE, strerror(errno)); - free(ram); - return -1; - } - /* We don't care about initial state, but we do want * to fault it all into RAM, otherwise the first iter * of the loop below will be quite slow. We can't use @@ -198,8 +186,6 @@ static int stressone(unsigned long long ramsizeMB) memset(ram, 0xfe, ramsizeMB * 1024 * 1024); if (random_bytes(data, PAGE_SIZE) < 0) { - free(ram); - free(data); return -1; } @@ -227,9 +213,6 @@ static int stressone(unsigned long long ramsizeMB) } } } - - free(data); - free(ram); } From patchwork Wed Jun 3 08:08:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mao Zhongyi X-Patchwork-Id: 1302846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49cM7p0VN1z9sSd for ; Wed, 3 Jun 2020 18:11:50 +1000 (AEST) Received: from localhost ([::1]:50114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOV1-0004Dr-Rk for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 04:11:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgOTE-0000Yl-4D for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:56 -0400 Received: from cmccmta1.chinamobile.com ([221.176.66.79]:3995) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOT9-0000Dh-R1 for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:55 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app01-12001 (RichMail) with SMTP id 2ee15ed75ab36a7-8ad9a; Wed, 03 Jun 2020 16:09:24 +0800 (CST) X-RM-TRANSID: 2ee15ed75ab36a7-8ad9a X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee85ed75aae43e-61016; Wed, 03 Jun 2020 16:09:24 +0800 (CST) X-RM-TRANSID: 2ee85ed75aae43e-61016 From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH 2/9] tests/migration: fix unreachable path in stress test Date: Wed, 3 Jun 2020 16:08:57 +0800 Message-Id: <20200603080904.997083-3-maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> References: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> Received-SPF: pass client-ip=221.176.66.79; envelope-from=maozhongyi@cmss.chinamobile.com; helo=cmccmta1.chinamobile.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 04:09:40 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mao Zhongyi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If stressone() or stress() exits it's because of a failure because the test runs forever otherwise, so change stressone and stress type to void to make the exit_failure() as the exit function of main(). Signed-off-by: Mao Zhongyi Reviewed-by: Laurent Vivier --- tests/migration/stress.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/migration/stress.c b/tests/migration/stress.c index f9626d50ee..a062ef6b55 100644 --- a/tests/migration/stress.c +++ b/tests/migration/stress.c @@ -167,7 +167,7 @@ static unsigned long long now(void) return (tv.tv_sec * 1000ull) + (tv.tv_usec / 1000ull); } -static int stressone(unsigned long long ramsizeMB) +static void stressone(unsigned long long ramsizeMB) { size_t pagesPerMB = 1024 * 1024 / PAGE_SIZE; g_autofree char *ram = g_malloc(ramsizeMB * 1024 * 1024); @@ -186,7 +186,7 @@ static int stressone(unsigned long long ramsizeMB) memset(ram, 0xfe, ramsizeMB * 1024 * 1024); if (random_bytes(data, PAGE_SIZE) < 0) { - return -1; + return; } before = now(); @@ -225,7 +225,7 @@ static void *stressthread(void *arg) return NULL; } -static int stress(unsigned long long ramsizeGB, int ncpus) +static void stress(unsigned long long ramsizeGB, int ncpus) { size_t i; unsigned long long ramsizeMB = ramsizeGB * 1024 / ncpus; @@ -238,8 +238,6 @@ static int stress(unsigned long long ramsizeGB, int ncpus) } stressone(ramsizeMB); - - return 0; } @@ -335,8 +333,7 @@ int main(int argc, char **argv) fprintf(stdout, "%s (%05d): INFO: RAM %llu GiB across %d CPUs\n", argv0, gettid(), ramsizeGB, ncpus); - if (stress(ramsizeGB, ncpus) < 0) - exit_failure(); + stress(ramsizeGB, ncpus); - exit_success(); + exit_failure(); } From patchwork Wed Jun 3 08:08:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mao Zhongyi X-Patchwork-Id: 1302853 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49cMC94YQcz9sSd for ; Wed, 3 Jun 2020 18:14:45 +1000 (AEST) Received: from localhost ([::1]:59854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOXr-0008Ai-F7 for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 04:14:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgOTU-00014e-QR for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:10:12 -0400 Received: from cmccmta1.chinamobile.com ([221.176.66.79]:7103) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOTT-0000Gz-87 for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:10:12 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app04-12004 (RichMail) with SMTP id 2ee45ed75ab47af-8b1ff; Wed, 03 Jun 2020 16:09:24 +0800 (CST) X-RM-TRANSID: 2ee45ed75ab47af-8b1ff X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee85ed75aae43e-6101a; Wed, 03 Jun 2020 16:09:24 +0800 (CST) X-RM-TRANSID: 2ee85ed75aae43e-6101a From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH 3/9] monitor/hmp-cmds: add units for migrate_parameters Date: Wed, 3 Jun 2020 16:08:58 +0800 Message-Id: <20200603080904.997083-4-maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> References: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> Received-SPF: pass client-ip=221.176.66.79; envelope-from=maozhongyi@cmss.chinamobile.com; helo=cmccmta1.chinamobile.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 04:09:40 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mao Zhongyi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When running: (qemu) info migrate_parameters announce-initial: 50 ms announce-max: 550 ms announce-step: 100 ms compress-wait-thread: on ... max-bandwidth: 33554432 bytes/second downtime-limit: 300 milliseconds x-checkpoint-delay: 20000 ... xbzrle-cache-size: 67108864 add units for the parameters 'x-checkpoint-delay' and 'xbzrle-cache-size', it's easier to read, also move milliseconds to ms to keep the same style. Signed-off-by: Mao Zhongyi Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Stefano Garzarella --- monitor/hmp-cmds.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 9c61e769ca..8c3e436b39 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -443,11 +443,11 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH), params->max_bandwidth); assert(params->has_downtime_limit); - monitor_printf(mon, "%s: %" PRIu64 " milliseconds\n", + monitor_printf(mon, "%s: %" PRIu64 " ms\n", MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT), params->downtime_limit); assert(params->has_x_checkpoint_delay); - monitor_printf(mon, "%s: %u\n", + monitor_printf(mon, "%s: %u ms\n", MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY), params->x_checkpoint_delay); assert(params->has_block_incremental); @@ -460,7 +460,7 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) monitor_printf(mon, "%s: %s\n", MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESSION), MultiFDCompression_str(params->multifd_compression)); - monitor_printf(mon, "%s: %" PRIu64 "\n", + monitor_printf(mon, "%s: %" PRIu64 " bytes\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); monitor_printf(mon, "%s: %" PRIu64 "\n", From patchwork Wed Jun 3 08:08:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mao Zhongyi X-Patchwork-Id: 1302841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49cM6F4qs8z9sV6 for ; Wed, 3 Jun 2020 18:10:29 +1000 (AEST) Received: from localhost ([::1]:41766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOTj-0000aS-BA for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 04:10:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgOTC-0000YD-2k for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:54 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:13034) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOT8-0000Db-Mq for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:53 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app08-12008 (RichMail) with SMTP id 2ee85ed75ab4862-8b2aa; Wed, 03 Jun 2020 16:09:25 +0800 (CST) X-RM-TRANSID: 2ee85ed75ab4862-8b2aa X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee85ed75aae43e-6101d; Wed, 03 Jun 2020 16:09:24 +0800 (CST) X-RM-TRANSID: 2ee85ed75aae43e-6101d From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH 4/9] monitor/hmp-cmds: don't silently output when running 'migrate_set_downtime' fails Date: Wed, 3 Jun 2020 16:08:59 +0800 Message-Id: <20200603080904.997083-5-maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> References: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> Received-SPF: pass client-ip=221.176.66.80; envelope-from=maozhongyi@cmss.chinamobile.com; helo=cmccmta2.chinamobile.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 04:09:39 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mao Zhongyi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Although 'migrate_set_downtime' has been deprecated and replaced with 'migrate_set_parameter downtime_limit', it has not been completely eliminated, possibly due to compatibility with older versions. I think as long as this old parameter is running, we should report appropriate message when something goes wrong, not be silent. before: (qemu) migrate_set_downtime -1 (qemu) after: (qemu) migrate_set_downtime -1 Error: Parameter 'downtime_limit' expects an integer in the range of 0 to 2000 seconds Signed-off-by: Mao Zhongyi Reviewed-by: Dr. David Alan Gilbert --- monitor/hmp-cmds.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 8c3e436b39..6938f1060e 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1188,8 +1188,11 @@ void hmp_migrate_pause(Monitor *mon, const QDict *qdict) /* Kept for backwards compatibility */ void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict) { + Error *err = NULL; + double value = qdict_get_double(qdict, "value"); - qmp_migrate_set_downtime(value, NULL); + qmp_migrate_set_downtime(value, &err); + hmp_handle_error(mon, err); } void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict) From patchwork Wed Jun 3 08:09:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mao Zhongyi X-Patchwork-Id: 1302843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49cM6G5BjZz9sV8 for ; Wed, 3 Jun 2020 18:10:30 +1000 (AEST) Received: from localhost ([::1]:41790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOTk-0000bd-FB for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 04:10:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgOTC-0000YT-Mx for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:54 -0400 Received: from cmccmta1.chinamobile.com ([221.176.66.79]:3996) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOT9-0000Di-Lf for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:54 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app01-12001 (RichMail) with SMTP id 2ee15ed75ab46aa-8ad9d; Wed, 03 Jun 2020 16:09:25 +0800 (CST) X-RM-TRANSID: 2ee15ed75ab46aa-8ad9d X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee85ed75aae43e-61021; Wed, 03 Jun 2020 16:09:25 +0800 (CST) X-RM-TRANSID: 2ee85ed75aae43e-61021 From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH 5/9] monitor/hmp-cmds: delete redundant Error check before invoke hmp_handle_error() Date: Wed, 3 Jun 2020 16:09:00 +0800 Message-Id: <20200603080904.997083-6-maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> References: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> Received-SPF: pass client-ip=221.176.66.79; envelope-from=maozhongyi@cmss.chinamobile.com; helo=cmccmta1.chinamobile.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 04:09:40 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mao Zhongyi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" hmp_handle_error() does Error check internally. Signed-off-by: Mao Zhongyi Reviewed-by: Dr. David Alan Gilbert --- monitor/hmp-cmds.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 6938f1060e..acdd6baff3 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1636,9 +1636,8 @@ void hmp_object_add(Monitor *mon, const QDict *qdict) obj = user_creatable_add_opts(opts, &err); qemu_opts_del(opts); - if (err) { - hmp_handle_error(mon, err); - } + hmp_handle_error(mon, err); + if (obj) { object_unref(obj); } From patchwork Wed Jun 3 08:09:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mao Zhongyi X-Patchwork-Id: 1302842 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49cM6D29nsz9sTv for ; Wed, 3 Jun 2020 18:10:28 +1000 (AEST) Received: from localhost ([::1]:41724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOTi-0000Z0-1q for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 04:10:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgOTB-0000Y7-EX for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:53 -0400 Received: from cmccmta3.chinamobile.com ([221.176.66.81]:5969) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOT8-0000DT-Lr for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:53 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app09-12009 (RichMail) with SMTP id 2ee95ed75ab43f3-8ab37; Wed, 03 Jun 2020 16:09:25 +0800 (CST) X-RM-TRANSID: 2ee95ed75ab43f3-8ab37 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee85ed75aae43e-61023; Wed, 03 Jun 2020 16:09:25 +0800 (CST) X-RM-TRANSID: 2ee85ed75aae43e-61023 From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH 6/9] monitor/hmp-cmds: add 'goto end' to reduce duplicate code. Date: Wed, 3 Jun 2020 16:09:01 +0800 Message-Id: <20200603080904.997083-7-maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> References: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> Received-SPF: pass client-ip=221.176.66.81; envelope-from=maozhongyi@cmss.chinamobile.com; helo=cmccmta3.chinamobile.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 04:09:37 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mao Zhongyi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Mao Zhongyi Reviewed-by: Dr. David Alan Gilbert --- monitor/hmp-cmds.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index acdd6baff3..e8cf72eb3a 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1501,8 +1501,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) read_only, BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN, &err); if (err) { - hmp_handle_error(mon, err); - return; + goto end; } } @@ -1511,6 +1510,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) &err); } +end: hmp_handle_error(mon, err); } @@ -1629,13 +1629,13 @@ void hmp_object_add(Monitor *mon, const QDict *qdict) opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err); if (err) { - hmp_handle_error(mon, err); - return; + goto end; } obj = user_creatable_add_opts(opts, &err); qemu_opts_del(opts); +end: hmp_handle_error(mon, err); if (obj) { From patchwork Wed Jun 3 08:09:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mao Zhongyi X-Patchwork-Id: 1302844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49cM6L2ZG0z9sV7 for ; Wed, 3 Jun 2020 18:10:34 +1000 (AEST) Received: from localhost ([::1]:42072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOTo-0000lX-0j for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 04:10:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgOTF-0000Z2-9K for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:57 -0400 Received: from cmccmta1.chinamobile.com ([221.176.66.79]:3997) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOTD-0000Dg-VK for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:57 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app01-12001 (RichMail) with SMTP id 2ee15ed75ab66af-8ada2; Wed, 03 Jun 2020 16:09:26 +0800 (CST) X-RM-TRANSID: 2ee15ed75ab66af-8ada2 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee85ed75aae43e-61025; Wed, 03 Jun 2020 16:09:26 +0800 (CST) X-RM-TRANSID: 2ee85ed75aae43e-61025 From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH 7/9] monitor/hmp-cmds: improvements for the 'info migrate' Date: Wed, 3 Jun 2020 16:09:02 +0800 Message-Id: <20200603080904.997083-8-maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> References: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> Received-SPF: pass client-ip=221.176.66.79; envelope-from=maozhongyi@cmss.chinamobile.com; helo=cmccmta1.chinamobile.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 04:09:40 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mao Zhongyi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When running: (qemu) info migrate globals: store-global-state: on only-migratable: off ... xbzrle transferred: 640892 kbytes xbzrle pages: 16645936 pages xbzrle cache miss: 1525426 xbzrle cache miss rate: 0.09 xbzrle encoding rate: 91.42 xbzrle overflow: 40896 ... compression pages: 377710 pages compression busy: 0 compression busy rate: 0.00 compressed size: 463169457 compression rate: 3.33 Add units for 'xbzrle cache miss' and 'compressed size', make it easier to read. Suggested-by: Dr. David Alan Gilbert Signed-off-by: Mao Zhongyi Reviewed-by: Dr. David Alan Gilbert --- docs/xbzrle.txt | 2 +- monitor/hmp-cmds.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/xbzrle.txt b/docs/xbzrle.txt index b431bdaf0f..385b4993f8 100644 --- a/docs/xbzrle.txt +++ b/docs/xbzrle.txt @@ -112,7 +112,7 @@ is recommended. cache size: H bytes xbzrle transferred: I kbytes xbzrle pages: J pages - xbzrle cache miss: K + xbzrle cache miss: K pages xbzrle overflow: L xbzrle cache-miss: the number of cache misses to date - high cache-miss rate diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index e8cf72eb3a..24f3e8e44d 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -299,7 +299,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info->xbzrle_cache->bytes >> 10); monitor_printf(mon, "xbzrle pages: %" PRIu64 " pages\n", info->xbzrle_cache->pages); - monitor_printf(mon, "xbzrle cache miss: %" PRIu64 "\n", + monitor_printf(mon, "xbzrle cache miss: %" PRIu64 " pages\n", info->xbzrle_cache->cache_miss); monitor_printf(mon, "xbzrle cache miss rate: %0.2f\n", info->xbzrle_cache->cache_miss_rate); @@ -316,8 +316,8 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) info->compression->busy); monitor_printf(mon, "compression busy rate: %0.2f\n", info->compression->busy_rate); - monitor_printf(mon, "compressed size: %" PRIu64 "\n", - info->compression->compressed_size); + monitor_printf(mon, "compressed size: %" PRIu64 " kbytes\n", + info->compression->compressed_size >> 10); monitor_printf(mon, "compression rate: %0.2f\n", info->compression->compression_rate); } From patchwork Wed Jun 3 08:09:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mao Zhongyi X-Patchwork-Id: 1302854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49cMDJ5gV2z9sSd for ; Wed, 3 Jun 2020 18:15:44 +1000 (AEST) Received: from localhost ([::1]:33780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOYn-0000rT-RW for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 04:15:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgOTV-000163-OV for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:10:13 -0400 Received: from cmccmta1.chinamobile.com ([221.176.66.79]:7104) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOTU-0000H0-4q for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:10:13 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app04-12004 (RichMail) with SMTP id 2ee45ed75ab67b4-8b204; Wed, 03 Jun 2020 16:09:26 +0800 (CST) X-RM-TRANSID: 2ee45ed75ab67b4-8b204 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee85ed75aae43e-61027; Wed, 03 Jun 2020 16:09:26 +0800 (CST) X-RM-TRANSID: 2ee85ed75aae43e-61027 From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH 8/9] docs/xbzrle: update 'cache miss rate' and 'encoding rate' to docs Date: Wed, 3 Jun 2020 16:09:03 +0800 Message-Id: <20200603080904.997083-9-maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> References: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> Received-SPF: pass client-ip=221.176.66.79; envelope-from=maozhongyi@cmss.chinamobile.com; helo=cmccmta1.chinamobile.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 04:09:40 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mao Zhongyi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Mao Zhongyi Reviewed-by: Dr. David Alan Gilbert --- docs/xbzrle.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/xbzrle.txt b/docs/xbzrle.txt index 385b4993f8..6bd1828f34 100644 --- a/docs/xbzrle.txt +++ b/docs/xbzrle.txt @@ -113,9 +113,11 @@ is recommended. xbzrle transferred: I kbytes xbzrle pages: J pages xbzrle cache miss: K pages - xbzrle overflow: L + xbzrle cache miss rate: L + xbzrle encoding rate: M + xbzrle overflow: N -xbzrle cache-miss: the number of cache misses to date - high cache-miss rate +xbzrle cache miss: the number of cache misses to date - high cache-miss rate indicates that the cache size is set too low. xbzrle overflow: the number of overflows in the decoding which where the delta could not be compressed. This can happen if the changes in the pages are too From patchwork Wed Jun 3 08:09:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mao Zhongyi X-Patchwork-Id: 1302851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49cM9N31C2z9sSd for ; Wed, 3 Jun 2020 18:13:12 +1000 (AEST) Received: from localhost ([::1]:54750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOWM-00066a-7L for incoming@patchwork.ozlabs.org; Wed, 03 Jun 2020 04:13:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgOTD-0000Yc-Fz for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:55 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:55316) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgOT9-0000EI-QI for qemu-devel@nongnu.org; Wed, 03 Jun 2020 04:09:55 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.15]) by rmmx-syy-dmz-app07-12007 (RichMail) with SMTP id 2ee75ed75ab7836-8b299; Wed, 03 Jun 2020 16:09:27 +0800 (CST) X-RM-TRANSID: 2ee75ed75ab7836-8b299 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr08-12008 (RichMail) with SMTP id 2ee85ed75aae43e-6102a; Wed, 03 Jun 2020 16:09:27 +0800 (CST) X-RM-TRANSID: 2ee85ed75aae43e-6102a From: Mao Zhongyi To: qemu-devel@nongnu.org Subject: [PATCH 9/9] migration/ram: calculate un/encoded_size only when needed. Date: Wed, 3 Jun 2020 16:09:04 +0800 Message-Id: <20200603080904.997083-10-maozhongyi@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> References: <20200603080904.997083-1-maozhongyi@cmss.chinamobile.com> Received-SPF: pass client-ip=221.176.66.80; envelope-from=maozhongyi@cmss.chinamobile.com; helo=cmccmta2.chinamobile.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/03 04:09:39 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mao Zhongyi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Mao Zhongyi --- migration/ram.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 41cc530d9d..ca20030b64 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -910,14 +910,15 @@ static void migration_update_rates(RAMState *rs, int64_t end_time) xbzrle_counters.cache_miss_rate = (double)(xbzrle_counters.cache_miss - rs->xbzrle_cache_miss_prev) / page_count; rs->xbzrle_cache_miss_prev = xbzrle_counters.cache_miss; - unencoded_size = (xbzrle_counters.pages - rs->xbzrle_pages_prev) * - TARGET_PAGE_SIZE; - encoded_size = xbzrle_counters.bytes - rs->xbzrle_bytes_prev; if (xbzrle_counters.pages == rs->xbzrle_pages_prev) { xbzrle_counters.encoding_rate = 0; - } else if (!encoded_size) { + } else if (xbzrle_counters.bytes == rs->xbzrle_bytes_prev) { xbzrle_counters.encoding_rate = UINT64_MAX; } else { + unencoded_size = (xbzrle_counters.pages - rs->xbzrle_pages_prev) * + TARGET_PAGE_SIZE; + encoded_size = xbzrle_counters.bytes - rs->xbzrle_bytes_prev; + xbzrle_counters.encoding_rate = unencoded_size / encoded_size; } rs->xbzrle_pages_prev = xbzrle_counters.pages;