From patchwork Wed May 20 20:42:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11561563 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 D260B1391 for ; Wed, 20 May 2020 20:51:10 +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 A8F9320758 for ; Wed, 20 May 2020 20:51:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="Icnfj42E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8F9320758 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:56794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbVgD-0003Tp-Gj for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 May 2020 16:51:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbVXp-0005mO-QN for qemu-devel@nongnu.org; Wed, 20 May 2020 16:42:29 -0400 Received: from mout.web.de ([212.227.17.11]:46605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbVXo-00076d-SV for qemu-devel@nongnu.org; Wed, 20 May 2020 16:42:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1590007341; bh=nBz36uKLAVET+svpvOg5XAEq13IOV9YVmFR9/mOLz4w=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=Icnfj42EK4XLxK3Hmpl0O/cZPwrSq8FNGXWw3P38gY8rC28tKiAtAbGvAR+BkTQ1o GOAqQtsPM/EgZY+m5iyOn7BOz3P9nnj0myxEZTWQ7+qtIRvHCUFZAplFGSW6yBzaCk iL8Pzzjz3HWDvJlzh+Zeqg+oaxeHiQgbwq4zhaqo= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.105]) by smtp.web.de (mrweb106 [213.165.67.124]) with ESMTPSA (Nemesis) id 1N7gbY-1iyPJX19Fq-014duS; Wed, 20 May 2020 22:42:21 +0200 Date: Wed, 20 May 2020 22:42:20 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v2 3/6] migration/colo.c: Flush ram cache only after receiving device state Message-ID: <38382499f40a1288d7e7f0fd59173b23660b69d9.1590007004.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:70VK6yf9zPvIdnGLOJ8M2cKJqRj4iOoKXJcVIcnOFJZzPSoVYNj /W4B8o6JwdveFklqYkTqR5b8DX2Jmd/q6TZ6zpnb49g/KyBLNyZ/RdZvES+XubtBOqcOBYA xU+U/iYWVUM+vGBZyVvH0/63RdogoaPExXThRppJodpg46vA8LJPv7WvLMNHB1RB/GAdNcp JCPWaHeq/us8AMnwM9X6g== X-UI-Out-Filterresults: notjunk:1;V03:K0:hJ/Iah1VeIk=:If04k/IPK1QczH/dN7wyaY 4/g133qSADLa6JuXzXuVIYO9syoAQ3Hp67u8JwDZ6BPbGi+nqICGebFUZorBlVOCpIhxVwoRV tVysWrKXE9zpNgPqFLPFvCkbLMdSB7i9e/JYXyd8gy87OO8Qkc/KLK0KegU9NMYFHEVk7uIO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+FcVnox NZQtkTyB1TbiJWEaU Received-SPF: pass client-ip=212.227.17.11; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/20 16:42:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: Hailiang Zhang , "Dr. David Alan Gilbert" , Juan Quintela Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" If we suceed in receiving ram state, but fail receiving the device state, there will be a mismatch between the two. Fix this by flushing the ram cache only after the vmstate has been received. Signed-off-by: Lukas Straub Reviewed-by: zhanghailiang --- migration/colo.c | 1 + migration/ram.c | 5 +---- migration/ram.h | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/migration/colo.c b/migration/colo.c index 6b2ad35aa4..2947363ae5 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -739,6 +739,7 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis, qemu_mutex_lock_iothread(); vmstate_loading = true; + colo_flush_ram_cache(); ret = qemu_load_device_state(fb); if (ret < 0) { error_setg(errp, "COLO: load device state failed"); diff --git a/migration/ram.c b/migration/ram.c index 04f13feb2e..5baec5fce9 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3313,7 +3313,7 @@ static bool postcopy_is_running(void) * Flush content of RAM cache into SVM's memory. * Only flush the pages that be dirtied by PVM or SVM or both. */ -static void colo_flush_ram_cache(void) +void colo_flush_ram_cache(void) { RAMBlock *block = NULL; void *dst_host; @@ -3585,9 +3585,6 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) } trace_ram_load_complete(ret, seq_iter); - if (!ret && migration_incoming_in_colo_state()) { - colo_flush_ram_cache(); - } return ret; } diff --git a/migration/ram.h b/migration/ram.h index 5ceaff7cb4..2eeaacfa13 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -65,6 +65,7 @@ int ram_dirty_bitmap_reload(MigrationState *s, RAMBlock *rb); /* ram cache */ int colo_init_ram_cache(void); +void colo_flush_ram_cache(void); void colo_release_ram_cache(void); void colo_incoming_start_dirty_log(void);