From nobody Wed Apr 24 23:03:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573130523; cv=none; d=zoho.com; s=zohoarc; b=jSBVUm1xzw/j43hkTsWj3/5B2mCxKt/9p8M3tUdcCq1L6e460z4W/x04fSEUJ70MwKmPNO8EgB7fXbbtnyZhpGshVDek+457uEzvJBGsTAM1+p/UY0cU3gc+jsLuUfW3r4F1u0HRk7el/reqWb/xWQdxvANU6pzm4ntVkYRpJKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573130523; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=+JV4xiUnW1a4LEpC40oRKvonmy+92bsg1HZ8/5hzXe4=; b=TC5Ey4VJJoMmfHCw4fQMjoTqlDBYi0Ri4mEMevUyTLZ/IeDgdNiadEsg3DYN7VB/ahECHXwwHFLAQL8mSLMBsBMhRsGbCSC9NbTkWI8hoOUuGSdAjgFNpsEGisDSHeo/WXxoq/D4e+aJtI3G3uMn8B5m9GsNRjW7oPChVyk+bW8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1573130523153763.0626056868268; Thu, 7 Nov 2019 04:42:03 -0800 (PST) Received: from localhost ([::1]:41644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSh6v-00062a-St for importer@patchew.org; Thu, 07 Nov 2019 07:42:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58910) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSh4e-0003wb-Me for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iSh4d-0002qa-Nb for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:40 -0500 Received: from mga06.intel.com ([134.134.136.31]:63430) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iSh4d-0002nd-Fw for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:39 -0500 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2019 04:39:36 -0800 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga005.jf.intel.com with ESMTP; 07 Nov 2019 04:39:35 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,278,1569308400"; d="scan'208";a="377408585" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [Patch v2 1/6] migration/postcopy: reduce memset when it is zero page and matches_target_page_size Date: Thu, 7 Nov 2019 20:39:02 +0800 Message-Id: <20191107123907.29791-2-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191107123907.29791-1-richardw.yang@linux.intel.com> References: <20191107123907.29791-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.31 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: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In this case, page_buffer content would not be used. Skip this to save some time. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Acked-by: Juan Quintela --- migration/ram.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index 99a98b2da4..7938a643d9 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4091,7 +4091,13 @@ static int ram_load_postcopy(QEMUFile *f) switch (flags & ~RAM_SAVE_FLAG_CONTINUE) { case RAM_SAVE_FLAG_ZERO: ch =3D qemu_get_byte(f); - memset(page_buffer, ch, TARGET_PAGE_SIZE); + /* + * Can skip to set page_buffer when + * this is a zero page and (block->page_size =3D=3D TARGET_PAG= E_SIZE). + */ + if (ch || !matches_target_page_size) { + memset(page_buffer, ch, TARGET_PAGE_SIZE); + } if (ch) { all_zero =3D false; } --=20 2.17.1 From nobody Wed Apr 24 23:03:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573130650; cv=none; d=zoho.com; s=zohoarc; b=dxjnW1oRbr42SXn7wpg3PzDSPraLk14uE254W/4JdlqSb5QXW6RkvMgQ9tWgshNVVrtXqveCUyhiIrRNL0GUEwM6EG1Q03gauzA2JNkd+gEsxEJ0ReOHc1sPEOf6/uOf8hx3P524309ks81XOpljbVWQaOufdox5vcAkNm8tDH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573130650; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Exa0RBVA9uRSf+UEq3FsHUqj8M3rMj83sAVx/kiO5fg=; b=AtQEyFF6VJpjMmjHTBDDMzU69YWXJ2xEGbCrql78KlMWJnZv0ECqztmh538CWYDF2fDlsN/SdPziDme3yPEAjWy3AREK/lqreHMnFD2LmKPzI4/ELJXP2hpI7SoygcLTDyhhJNC4EEUEGMl2mYvIKcQnaeR2x+AwGsvF24ueTbQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1573130650220329.8241167991238; Thu, 7 Nov 2019 04:44:10 -0800 (PST) Received: from localhost ([::1]:41671 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSh8z-0000kv-5z for importer@patchew.org; Thu, 07 Nov 2019 07:44:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58919) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSh4f-0003xk-4A for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iSh4e-0002r1-6X for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:41 -0500 Received: from mga06.intel.com ([134.134.136.31]:63430) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iSh4d-0002nd-U1 for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:40 -0500 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2019 04:39:37 -0800 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga005.jf.intel.com with ESMTP; 07 Nov 2019 04:39:36 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,278,1569308400"; d="scan'208";a="377408589" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [Patch v2 2/6] migration/postcopy: wait for decompress thread in precopy Date: Thu, 7 Nov 2019 20:39:03 +0800 Message-Id: <20191107123907.29791-3-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191107123907.29791-1-richardw.yang@linux.intel.com> References: <20191107123907.29791-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.31 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: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Compress is not supported with postcopy, it is safe to wait for decompress thread just in precopy. This is a preparation for later patch. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- migration/ram.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 7938a643d9..f59e3fe197 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4375,6 +4375,7 @@ static int ram_load_precopy(QEMUFile *f) } } =20 + ret |=3D wait_for_decompress_done(); return ret; } =20 @@ -4406,8 +4407,6 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) } else { ret =3D ram_load_precopy(f); } - - ret |=3D wait_for_decompress_done(); } trace_ram_load_complete(ret, seq_iter); =20 --=20 2.17.1 From nobody Wed Apr 24 23:03:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573130517; cv=none; d=zoho.com; s=zohoarc; b=d9tWLlR8j/oqYZuLFxLJkxfHs5PcqFXVgGhbwIMtybPsqmFsiJy+DCYwXYxp7OC0q6beJ7/xBNJe5APCk+GhIrjZnqdFfTxJ+gysiG8mBoJTHGG/a2J99M86VA4mkRuOUea5lmv8g/Y0xOJqdO8KndVkaz3nBALmp+7hfysxu/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573130517; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ZWJNO4V3osWjcagEUNSSUIwI4ZgB4mqBgMDjQUPW9OA=; b=DleSDAcnU2dTZPYH7xXFU5iul0zfyynUdnigDoeB0vqpZpxVl+ZeqXgcYfxFKeOwptHlDLWzig7s4TpucgMDyz2zCSBgDYb5yO+3HWMrQfFP9X5MbG/u4pN/CC7hbUoHD5Qxu8YEO74dGXZLFaX67wG00H8txT8e7fcHNwDCWrY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157313051741345.2497090826721; Thu, 7 Nov 2019 04:41:57 -0800 (PST) Received: from localhost ([::1]:41640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSh6n-0005uq-3D for importer@patchew.org; Thu, 07 Nov 2019 07:41:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58932) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSh4f-000409-Pn for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iSh4e-0002rX-M0 for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:41 -0500 Received: from mga06.intel.com ([134.134.136.31]:63430) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iSh4e-0002nd-Cz for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:40 -0500 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2019 04:39:39 -0800 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga005.jf.intel.com with ESMTP; 07 Nov 2019 04:39:38 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,278,1569308400"; d="scan'208";a="377408594" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [Patch v2 3/6] migration/postcopy: count target page number to decide the place_needed Date: Thu, 7 Nov 2019 20:39:04 +0800 Message-Id: <20191107123907.29791-4-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191107123907.29791-1-richardw.yang@linux.intel.com> References: <20191107123907.29791-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.31 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: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In postcopy, it requires to place whole host page instead of target page. Currently, it relies on the page offset to decide whether this is the last target page. We also can count the target page number during the iteration. When the number of target page equals (host page size / target page size), this means it is the last target page in the host page. This is a preparation for non-ordered target page transmission. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- migration/ram.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index f59e3fe197..5c05376d8d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4017,6 +4017,7 @@ static int ram_load_postcopy(QEMUFile *f) void *postcopy_host_page =3D mis->postcopy_tmp_page; void *last_host =3D NULL; bool all_zero =3D false; + int target_pages =3D 0; =20 while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) { ram_addr_t addr; @@ -4051,6 +4052,7 @@ static int ram_load_postcopy(QEMUFile *f) ret =3D -EINVAL; break; } + target_pages++; matches_target_page_size =3D block->page_size =3D=3D TARGET_PA= GE_SIZE; /* * Postcopy requires that we place whole host pages atomically; @@ -4082,8 +4084,10 @@ static int ram_load_postcopy(QEMUFile *f) * If it's the last part of a host page then we place the host * page */ - place_needed =3D (((uintptr_t)host + TARGET_PAGE_SIZE) & - (block->page_size - 1)) =3D=3D 0; + if (target_pages =3D=3D (block->page_size / TARGET_PAGE_SIZE))= { + place_needed =3D true; + target_pages =3D 0; + } place_source =3D postcopy_host_page; } last_host =3D host; --=20 2.17.1 From nobody Wed Apr 24 23:03:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573130522; cv=none; d=zoho.com; s=zohoarc; b=LFiH8eE+8nAaD/IO9k9pglgRzyfLFw0iJWrOGKDOhyly52GlA8RvjVrkXzmBvURNswXOIr2bq/2rE8fMa83F7KF01Yw9FldBl59mr+YrEsGK7ZaAf8pHG2FoaXHgmxlql9s7rwtf8W5YRAvldmKpyTsmY74Uv49PkLtK9O8Zif4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573130522; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=p2YWUbKhWHtdMUAskHidy01h01yZXTKliiAZ7KnwQdM=; b=JMyvSV1Ck4UeyQPjVM7CobDelAvD25dUtHpTvVYcEeRYwpFJrcDa97DDD7GpcfDfSHflecGrj3EJv1UPZXv8A3R7FS0MT5uw8xmZrA/zaE9Cs1xRZLRttrz0htu77TkgLd7HO9mVO/akcgEdM6SVX8oSHLYnepzsEXY5JgQhBpE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1573130522595957.4303715965789; Thu, 7 Nov 2019 04:42:02 -0800 (PST) Received: from localhost ([::1]:41642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSh6v-0005zN-4H for importer@patchew.org; Thu, 07 Nov 2019 07:42:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58935) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSh4f-00040i-WE for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iSh4e-0002rt-W6 for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:41 -0500 Received: from mga06.intel.com ([134.134.136.31]:63431) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iSh4e-0002qi-OF for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:40 -0500 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2019 04:39:40 -0800 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga005.jf.intel.com with ESMTP; 07 Nov 2019 04:39:39 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,278,1569308400"; d="scan'208";a="377408597" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [Patch v2 4/6] migration/postcopy: set all_zero to true on the first target page Date: Thu, 7 Nov 2019 20:39:05 +0800 Message-Id: <20191107123907.29791-5-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191107123907.29791-1-richardw.yang@linux.intel.com> References: <20191107123907.29791-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.31 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: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For the first target page, all_zero is set to true for this round check. After target_pages introduced, we could leverage this variable instead of checking the address offset. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- migration/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/ram.c b/migration/ram.c index 5c05376d8d..b5759793a9 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4067,7 +4067,7 @@ static int ram_load_postcopy(QEMUFile *f) page_buffer =3D postcopy_host_page + ((uintptr_t)host & (block->page_size - 1)); /* If all TP are zero then we can optimise the place */ - if (!((uintptr_t)host & (block->page_size - 1))) { + if (target_pages =3D=3D 1) { all_zero =3D true; } else { /* not the 1st TP within the HP */ --=20 2.17.1 From nobody Wed Apr 24 23:03:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573130686; cv=none; d=zoho.com; s=zohoarc; b=Pw6G1hbknj7C+KSlAJZKJCzaf6N63ecd7J/dlwd2fnsO565Y/VswtGjNEJNAoAT0klt+XlRIsX9zb+PC5gCyHtoWYvpgkDA8bfl8jH9Y/3FDFUEkKs1nVfrWQxntPHKhqGo1K3SdqYGcJEi8mdB29gtn1GvC/N01z6VSgSk5WOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573130686; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=owxqvA7lMzhYbQQP8WbBQ52dZtEVTX23RMaCGlAFHtk=; b=Lx/YfqZgBbS3Rjkmku8bnpJp5fARRLdR2YJOXg59enDlmc55IeZznFMT52tMW0MrEwsbXesG6cSbzuD/zZtcsowU8xOVuoN+qLKXyPa4+ptrYrHRINyWDGhaAh0hI3lZsNwjIIQrjffoqhsm4oKbu9oOS1yQ8COPdf55Grno4BA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1573130686300857.4330261815684; Thu, 7 Nov 2019 04:44:46 -0800 (PST) Received: from localhost ([::1]:41672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSh9Y-0001Qx-VL for importer@patchew.org; Thu, 07 Nov 2019 07:44:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58954) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSh4i-00049h-K0 for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iSh4h-0002uD-EO for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:44 -0500 Received: from mga06.intel.com ([134.134.136.31]:63434) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iSh4h-0002tE-6q for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:43 -0500 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2019 04:39:42 -0800 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga005.jf.intel.com with ESMTP; 07 Nov 2019 04:39:41 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,278,1569308400"; d="scan'208";a="377408601" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [Patch v2 5/6] migration/postcopy: enable random order target page arrival Date: Thu, 7 Nov 2019 20:39:06 +0800 Message-Id: <20191107123907.29791-6-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191107123907.29791-1-richardw.yang@linux.intel.com> References: <20191107123907.29791-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.31 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: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After using number of target page received to track one host page, we could have the capability to handle random order target page arrival in one host page. This is a preparation for enabling compress during postcopy. Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- v2: * use uintptr_t to calculate place_dest * check target pages belongs to the same host page --- migration/ram.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index b5759793a9..666ad69284 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4015,7 +4015,7 @@ static int ram_load_postcopy(QEMUFile *f) MigrationIncomingState *mis =3D migration_incoming_get_current(); /* Temporary page that is later 'placed' */ void *postcopy_host_page =3D mis->postcopy_tmp_page; - void *last_host =3D NULL; + void *this_host =3D NULL; bool all_zero =3D false; int target_pages =3D 0; =20 @@ -4062,24 +4062,26 @@ static int ram_load_postcopy(QEMUFile *f) * that's moved into place later. * The migration protocol uses, possibly smaller, target-pages * however the source ensures it always sends all the componen= ts - * of a host page in order. + * of a host page in one chunk. */ page_buffer =3D postcopy_host_page + ((uintptr_t)host & (block->page_size - 1)); /* If all TP are zero then we can optimise the place */ if (target_pages =3D=3D 1) { all_zero =3D true; + this_host =3D (void *)QEMU_ALIGN_DOWN((uintptr_t)host, + block->page_size); } else { /* not the 1st TP within the HP */ - if (host !=3D (last_host + TARGET_PAGE_SIZE)) { - error_report("Non-sequential target page %p/%p", - host, last_host); + if (QEMU_ALIGN_DOWN((uintptr_t)host, block->page_size) != =3D + (uintptr_t)this_host) { + error_report("Non-same host page %p/%p", + host, this_host); ret =3D -EINVAL; break; } } =20 - /* * If it's the last part of a host page then we place the host * page @@ -4090,7 +4092,6 @@ static int ram_load_postcopy(QEMUFile *f) } place_source =3D postcopy_host_page; } - last_host =3D host; =20 switch (flags & ~RAM_SAVE_FLAG_CONTINUE) { case RAM_SAVE_FLAG_ZERO: @@ -4143,7 +4144,8 @@ static int ram_load_postcopy(QEMUFile *f) =20 if (!ret && place_needed) { /* This gets called at the last target page in the host page */ - void *place_dest =3D host + TARGET_PAGE_SIZE - block->page_siz= e; + void *place_dest =3D (void *)QEMU_ALIGN_DOWN((uintptr_t)host, + block->page_size); =20 if (all_zero) { ret =3D postcopy_place_page_zero(mis, place_dest, --=20 2.17.1 From nobody Wed Apr 24 23:03:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573130739; cv=none; d=zoho.com; s=zohoarc; b=Ut24uM5TBkX24Scw4xlBlwFrPed1bpxUCoS94Xks/8y6BGh/ubPrK+zSqVZ88I21MOb0YrkWAL1zS5lR4TyVmF2oLFPK24fIzGMtyPD8mGbLA0YYzdGNjqtVplUGsHMM8+zgMsq3GDlNp73yqVI9fGw4FpF2libnotydmWpbays= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573130739; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=8u38IRlaXhHoqRG0waozGWcEpmSGSu2FKwuAEGeMb98=; b=TwDl+Q/PNRpIXkhf7HzLtKncJNIuTfrFoYQU4MjN2t+MSsTsGQnOok9JpThUiqRkeB2a7y/d0P3WPv0k9+jkSbXB/aV7Fn45bpaJ1A7JXkehT2PlRI7m8eDEcTIeXGyBWTAnVU6roZEQ8cfeAdTHGhORrLC7UVoo4RKhpuUC8ms= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1573130739749328.679039578588; Thu, 7 Nov 2019 04:45:39 -0800 (PST) Received: from localhost ([::1]:41688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iShAQ-0002cH-Mk for importer@patchew.org; Thu, 07 Nov 2019 07:45:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58965) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSh4k-0004DL-0a for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iSh4i-0002v7-K7 for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:45 -0500 Received: from mga06.intel.com ([134.134.136.31]:63434) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iSh4i-0002tE-9G for qemu-devel@nongnu.org; Thu, 07 Nov 2019 07:39:44 -0500 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2019 04:39:44 -0800 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga005.jf.intel.com with ESMTP; 07 Nov 2019 04:39:42 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,278,1569308400"; d="scan'208";a="377408609" From: Wei Yang To: quintela@redhat.com, dgilbert@redhat.com Subject: [Patch v2 6/6] migration/postcopy: enable compress during postcopy Date: Thu, 7 Nov 2019 20:39:07 +0800 Message-Id: <20191107123907.29791-7-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191107123907.29791-1-richardw.yang@linux.intel.com> References: <20191107123907.29791-1-richardw.yang@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.31 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: qemu-devel@nongnu.org, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" postcopy requires to place a whole host page, while migration thread migrate memory in target page size. This makes postcopy need to collect all target pages in one host page before placing via userfaultfd. To enable compress during postcopy, there are two problems to solve: 1. Random order for target page arrival 2. Target pages in one host page arrives without interrupt by target page from other host page The first one is handled by previous cleanup patch. This patch handles the second one by: 1. Flush compress thread for each host page 2. Wait for decompress thread for before placing host page Signed-off-by: Wei Yang Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- migration/migration.c | 11 ----------- migration/ram.c | 28 +++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 354ad072fa..3c926a3ae3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1005,17 +1005,6 @@ static bool migrate_caps_check(bool *cap_list, #endif =20 if (cap_list[MIGRATION_CAPABILITY_POSTCOPY_RAM]) { - if (cap_list[MIGRATION_CAPABILITY_COMPRESS]) { - /* The decompression threads asynchronously write into RAM - * rather than use the atomic copies needed to avoid - * userfaulting. It should be possible to fix the decompressi= on - * threads for compatibility in future. - */ - error_setg(errp, "Postcopy is not currently compatible " - "with compression"); - return false; - } - /* This check is reasonably expensive, so only when it's being * set the first time, also it's only the destination that needs * special support. diff --git a/migration/ram.c b/migration/ram.c index 666ad69284..0d53786311 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3449,6 +3449,14 @@ static int ram_save_iterate(QEMUFile *f, void *opaqu= e) =20 rs->target_page_count +=3D pages; =20 + /* + * During postcopy, it is necessary to make sure one whole host + * page is sent in one chunk. + */ + if (migrate_postcopy_ram()) { + flush_compressed_data(rs); + } + /* * we want to check in the 1st loop, just in case it was the 1= st * time and we had to sync the dirty bitmap. @@ -4026,6 +4034,7 @@ static int ram_load_postcopy(QEMUFile *f) void *place_source =3D NULL; RAMBlock *block =3D NULL; uint8_t ch; + int len; =20 addr =3D qemu_get_be64(f); =20 @@ -4043,7 +4052,8 @@ static int ram_load_postcopy(QEMUFile *f) =20 trace_ram_load_postcopy_loop((uint64_t)addr, flags); place_needed =3D false; - if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE)) { + if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE | + RAM_SAVE_FLAG_COMPRESS_PAGE)) { block =3D ram_block_from_stream(f, flags); =20 host =3D host_from_ram_block_offset(block, addr); @@ -4126,6 +4136,17 @@ static int ram_load_postcopy(QEMUFile *f) TARGET_PAGE_SIZE); } break; + case RAM_SAVE_FLAG_COMPRESS_PAGE: + all_zero =3D false; + len =3D qemu_get_be32(f); + if (len < 0 || len > compressBound(TARGET_PAGE_SIZE)) { + error_report("Invalid compressed data length: %d", len); + ret =3D -EINVAL; + break; + } + decompress_data_with_multi_threads(f, page_buffer, len); + break; + case RAM_SAVE_FLAG_EOS: /* normal exit */ multifd_recv_sync_main(); @@ -4137,6 +4158,11 @@ static int ram_load_postcopy(QEMUFile *f) break; } =20 + /* Got the whole host page, wait for decompress before placing. */ + if (place_needed) { + ret |=3D wait_for_decompress_done(); + } + /* Detect for any possible file errors */ if (!ret && qemu_file_get_error(f)) { ret =3D qemu_file_get_error(f); --=20 2.17.1