From patchwork Fri May 15 04:28:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 11550433 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2819A90 for ; Fri, 15 May 2020 04:39:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 081942065F for ; Fri, 15 May 2020 04:39:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 081942065F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZS8Q-0000LM-33 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 15 May 2020 00:39:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZS7Y-0007gw-GV for qemu-devel@nongnu.org; Fri, 15 May 2020 00:38:52 -0400 Received: from mga12.intel.com ([192.55.52.136]:45610) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZS7W-0007bS-P8 for qemu-devel@nongnu.org; Fri, 15 May 2020 00:38:51 -0400 IronPort-SDR: Cik33kwohMCBEVjstyJBBnTS0s8KR56j0zWX1j3D3oQCrk2cvwZsus+B2agWzxWEOsLsna6NSI yWGjVk3M+W2w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2020 21:38:47 -0700 IronPort-SDR: E9lrJQFjdy4w0aWC5ksuBarHrbvT6jj9GapituklWZPvNMCwgxx/6O8xG/usa/qggzzyOjHfWS pGhC6Yvo3A4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,394,1583222400"; d="scan'208";a="263069534" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga003.jf.intel.com with ESMTP; 14 May 2020 21:38:45 -0700 From: Zhang Chen To: "Dr . David Alan Gilbert" , Juan Quintela , Zhanghailiang , qemu-dev Subject: [PATCH 1/3] migration/colo: Optimize COLO boot code path Date: Fri, 15 May 2020 12:28:16 +0800 Message-Id: <20200515042818.17908-2-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200515042818.17908-1-chen.zhang@intel.com> References: <20200515042818.17908-1-chen.zhang@intel.com> Received-SPF: pass client-ip=192.55.52.136; envelope-from=chen.zhang@intel.com; helo=mga12.intel.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:38:46 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, FROM_ADDR_WS=2.999, FROM_WSP_TRAIL=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, 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: Zhang Chen , Jason Wang , Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Zhang Chen No need to reuse MIGRATION_STATUS_ACTIVE boot COLO. Signed-off-by: Zhang Chen Reviewed-by: zhanghailiang --- migration/colo.c | 2 -- migration/migration.c | 17 ++++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index d015d4f84e..5ef69b885d 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -669,8 +669,6 @@ void migrate_start_colo_process(MigrationState *s) colo_checkpoint_notify, s); qemu_sem_init(&s->colo_exit_sem, 0); - migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, - MIGRATION_STATUS_COLO); colo_process_checkpoint(s); qemu_mutex_lock_iothread(); } diff --git a/migration/migration.c b/migration/migration.c index 0bb042a0f7..c889ef6eb7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2972,7 +2972,10 @@ static void migration_completion(MigrationState *s) goto fail_invalidate; } - if (!migrate_colo_enabled()) { + if (migrate_colo_enabled()) { + migrate_set_state(&s->state, current_active_state, + MIGRATION_STATUS_COLO); + } else { migrate_set_state(&s->state, current_active_state, MIGRATION_STATUS_COMPLETED); } @@ -3304,12 +3307,7 @@ static void migration_iteration_finish(MigrationState *s) migration_calculate_complete(s); runstate_set(RUN_STATE_POSTMIGRATE); break; - - case MIGRATION_STATUS_ACTIVE: - /* - * We should really assert here, but since it's during - * migration, let's try to reduce the usage of assertions. - */ + case MIGRATION_STATUS_COLO: if (!migrate_colo_enabled()) { error_report("%s: critical error: calling COLO code without " "COLO enabled", __func__); @@ -3319,6 +3317,11 @@ static void migration_iteration_finish(MigrationState *s) * Fixme: we will run VM in COLO no matter its old running state. * After exited COLO, we will keep running. */ + case MIGRATION_STATUS_ACTIVE: + /* + * We should really assert here, but since it's during + * migration, let's try to reduce the usage of assertions. + */ s->vm_was_running = true; /* Fallthrough */ case MIGRATION_STATUS_FAILED: From patchwork Fri May 15 04:28:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 11550435 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 023EE90 for ; Fri, 15 May 2020 04:41:31 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D56B72065F for ; Fri, 15 May 2020 04:41:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D56B72065F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZSA6-0003dH-2y for patchwork-qemu-devel@patchwork.kernel.org; Fri, 15 May 2020 00:41:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZS7Y-0007gy-Gl for qemu-devel@nongnu.org; Fri, 15 May 2020 00:38:52 -0400 Received: from mga12.intel.com ([192.55.52.136]:45615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZS7X-0007ba-DN for qemu-devel@nongnu.org; Fri, 15 May 2020 00:38:52 -0400 IronPort-SDR: QlPBh03/Qp70aLKij7AL8yCJ9x2XRSoxhg6uXzEYVU/4RzUIwrQNByfm0bL/0LVzSo/hgSaoUd t5wSDG/qB/pg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2020 21:38:50 -0700 IronPort-SDR: Vjl0r2p4InwZqaLfztA0ibOkH4hZhmOeSJ50BOla12qOSjznZqRJ8f/fPk11QMPJ6FesE03AR3 6+s4oQxcFlZg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,394,1583222400"; d="scan'208";a="263069541" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga003.jf.intel.com with ESMTP; 14 May 2020 21:38:48 -0700 From: Zhang Chen To: "Dr . David Alan Gilbert" , Juan Quintela , Zhanghailiang , qemu-dev Subject: [PATCH 2/3] migration/colo: Update checkpoint time lately Date: Fri, 15 May 2020 12:28:17 +0800 Message-Id: <20200515042818.17908-3-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200515042818.17908-1-chen.zhang@intel.com> References: <20200515042818.17908-1-chen.zhang@intel.com> Received-SPF: pass client-ip=192.55.52.136; envelope-from=chen.zhang@intel.com; helo=mga12.intel.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:38:46 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, FROM_ADDR_WS=2.999, FROM_WSP_TRAIL=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, 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: Zhang Chen , Jason Wang , Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Zhang Chen Previous operation(like vm_start and replication_start_all) will consume extra time for first forced synchronization, so reduce it in this patch. Signed-off-by: Zhang Chen Reviewed-by: zhanghailiang --- migration/colo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 5ef69b885d..d5bced22cb 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -531,7 +531,6 @@ static void colo_process_checkpoint(MigrationState *s) { QIOChannelBuffer *bioc; QEMUFile *fb = NULL; - int64_t current_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); Error *local_err = NULL; int ret; @@ -580,8 +579,8 @@ static void colo_process_checkpoint(MigrationState *s) qemu_mutex_unlock_iothread(); trace_colo_vm_state_change("stop", "run"); - timer_mod(s->colo_delay_timer, - current_time + s->parameters.x_checkpoint_delay); + timer_mod(s->colo_delay_timer, qemu_clock_get_ms(QEMU_CLOCK_HOST) + + s->parameters.x_checkpoint_delay); while (s->state == MIGRATION_STATUS_COLO) { if (failover_get_state() != FAILOVER_STATUS_NONE) { From patchwork Fri May 15 04:28:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 11550437 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A7FB414C0 for ; Fri, 15 May 2020 04:41:31 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8816D2065F for ; Fri, 15 May 2020 04:41:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8816D2065F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jZSA6-0003fo-QQ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 15 May 2020 00:41:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZS7Z-0007hG-Lk for qemu-devel@nongnu.org; Fri, 15 May 2020 00:38:53 -0400 Received: from mga12.intel.com ([192.55.52.136]:45615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZS7Y-0007ba-SZ for qemu-devel@nongnu.org; Fri, 15 May 2020 00:38:53 -0400 IronPort-SDR: 6uJ4RuuYXP6EPxfjVprHDOrraQl8bTfLtTcGM5oxp3syS+AifWobZeY3Rv3iZy8uXT1zHzdy81 cIlEneFBf+iQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2020 21:38:52 -0700 IronPort-SDR: n09WbtQhRsoBAEGUiaJLXbb9LWzPvf/OHs/d38ePO15mz9yhF3tTgM0/OokPHh0Qijtteg8Gq1 aOgFKGbRWlmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,394,1583222400"; d="scan'208";a="263069548" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga003.jf.intel.com with ESMTP; 14 May 2020 21:38:50 -0700 From: Zhang Chen To: "Dr . David Alan Gilbert" , Juan Quintela , Zhanghailiang , qemu-dev Subject: [PATCH 3/3] migration/colo: Merge multi checkpoint request into one. Date: Fri, 15 May 2020 12:28:18 +0800 Message-Id: <20200515042818.17908-4-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200515042818.17908-1-chen.zhang@intel.com> References: <20200515042818.17908-1-chen.zhang@intel.com> Received-SPF: pass client-ip=192.55.52.136; envelope-from=chen.zhang@intel.com; helo=mga12.intel.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/15 00:38:46 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, FROM_ADDR_WS=2.999, FROM_WSP_TRAIL=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, 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: Zhang Chen , Jason Wang , Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Zhang Chen When COLO guest occur issues, COLO-compare will catch lots of different network packet and trigger notification multi times, force periodic may happen at the same time. So this can be efficient merge checkpoint request within COLO_CHECKPOINT_INTERVAL. Signed-off-by: Zhang Chen --- migration/colo.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index d5bced22cb..e6a7d8c6e2 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -47,6 +47,9 @@ static COLOMode last_colo_mode; #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) +/* Default COLO_CHECKPOINT_INTERVAL is 1000 ms */ +#define COLO_CHECKPOINT_INTERVAL 1000 + bool migration_in_colo_state(void) { MigrationState *s = migrate_get_current(); @@ -651,13 +654,20 @@ out: void colo_checkpoint_notify(void *opaque) { MigrationState *s = opaque; - int64_t next_notify_time; + int64_t now = qemu_clock_get_ms(QEMU_CLOCK_HOST); - qemu_sem_post(&s->colo_checkpoint_sem); - s->colo_checkpoint_time = qemu_clock_get_ms(QEMU_CLOCK_HOST); - next_notify_time = s->colo_checkpoint_time + - s->parameters.x_checkpoint_delay; - timer_mod(s->colo_delay_timer, next_notify_time); + /* + * When COLO guest occur issues, COLO-compare will catch lots of + * different network packet and trigger notification multi times, + * force periodic may happen at the same time. So this can be + * efficient merge checkpoint request within COLO_CHECKPOINT_INTERVAL. + */ + if (now > s->colo_checkpoint_time + COLO_CHECKPOINT_INTERVAL) { + qemu_sem_post(&s->colo_checkpoint_sem); + timer_mod(s->colo_delay_timer, now + + s->parameters.x_checkpoint_delay); + s->colo_checkpoint_time = now; + } } void migrate_start_colo_process(MigrationState *s)