From patchwork Mon May 11 11:10:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11540319 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 6AF7115AB for ; Mon, 11 May 2020 11:20:29 +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 41C6520722 for ; Mon, 11 May 2020 11:20:29 +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="BU0YYEY8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41C6520722 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]:34838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jY6U0-0004lP-9e for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 May 2020 07:20:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jY6Ks-00050F-F7 for qemu-devel@nongnu.org; Mon, 11 May 2020 07:11:02 -0400 Received: from mout.web.de ([212.227.15.3]:34051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jY6Kr-0005l1-Ir for qemu-devel@nongnu.org; Mon, 11 May 2020 07:11:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1589195453; bh=dZ8rX0irz/4KH8600VHSFn1CNdmEGizP4s4ww9kK2Ho=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=BU0YYEY81LWwOVoniojx3ZwInETAbh5nNx3nTJs79IxHNK2BjKXmIj8JGEE22yHcN hk7LaR1/k1fxIvmaZsoCMtCcKL7qnRseFWkwTB9mFXZeBVm5MW2sD5LX2jXyMPvBgo AUjtoJcga/XkTBbaUc0T4dufWUhKTszzo+5j943I= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.192]) by smtp.web.de (mrweb005 [213.165.67.108]) with ESMTPSA (Nemesis) id 1Mhnvw-1iuciC44J6-00dpwi; Mon, 11 May 2020 13:10:53 +0200 Date: Mon, 11 May 2020 13:10:51 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH 3/6] migration/colo.c: Flush ram cache only after receiving device state Message-ID: <3289d007d494cb0e2f05b1cf4ae6a78d300fede3.1589193382.git.lukasstraub2@web.de> In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:Q43gYz642FHDiJiOKUcWlXH5M8tCMurNfc9+BrsFD4f//0Cl3r0 xOcLddf14yOmnxbkR8uaLWB5YbHmgNxwVUaWsAi0Hp0952L5A3n4mhnWQw402KvYWX2N19L aucJojiHjtXA+AMztvOMsH8CZ9CVF1i+Z0weSWMaEODLj3TnDh1HinCJ02kskNb7KDw9Sat ZWeG0x2dTrqJzD3H3HwQw== X-UI-Out-Filterresults: notjunk:1;V03:K0:+mUVSYNyHrg=:wVx8sGujcmxz0dEFzpXZ8C +ZHuteoBY98PsfVuNeLzp2tQuZxhKk6VZPYj9Z2E3fcWsw85fQnN78HpMTojTk95GilLPcc+1 9SIdwgbsII3iNnbR+BW2BWWNKYDX6oYubx/DRP7uqIkGKpX790PkUqxr05N4I0EG7sm6uxj9F 7Oc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qdgGuE s2xD1JQ7GZ+/is1J1 Received-SPF: pass client-ip=212.227.15.3; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/11 07:11:00 X-ACL-Warn: Detected OS = Linux 3.11 and newer 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 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(-) 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);