From nobody Wed Nov 27 18:43:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1697722965; cv=none; d=zohomail.com; s=zohoarc; b=KFePPDL4WxTuhnus7/GrpVtDKbAEEST6W+xdd+qUxAN4RJEGk1EpWAjP7aRe4Fr0xSGMxslXZxsHcpK5NOupr76cmwFbsYQWYgZGuAH2dv7tKQ66AEdqTA3ZUo2Df6ds0Jo9XjbRtk2tSbwF94wN/zlQIG24cZ5h0U2hLMze4kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697722965; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NI7bXi0Vq9JMaQGKj6XzV+77wJZQ2SUBkwFlCwgVN2E=; b=izYERVArbnuBt4sTpeoB3CcKkHtMWkJnSlf4zgJzLanft7JHJA9keLYZZwMtYCBDu7ZZZTSL+xYjrIf5WdrFX9biUJvYFFlbQaW5QpOxJWjIUQe5A9HXe73nv10X3lgOUtNrAeXbgnyR1L/ykJrCcbLdCIHgUXjFehP2bXMRzAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697722965589776.2706362241233; Thu, 19 Oct 2023 06:42:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtTEu-0000nK-JC; Thu, 19 Oct 2023 09:39:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtNyg-0003AX-GM for qemu-devel@nongnu.org; Thu, 19 Oct 2023 04:02:01 -0400 Received: from mgamail.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtNyd-0006LX-4s for qemu-devel@nongnu.org; Thu, 19 Oct 2023 04:01:57 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 01:01:53 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by fmsmga006.fm.intel.com with ESMTP; 19 Oct 2023 01:01:50 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697702515; x=1729238515; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=t9BdIS+sJlH+qsQMBb7HkqEKoFxNHzvd5KGj9Dty4l8=; b=HcTlZ4rQD9ODJ2F21eZOpOTXwzeOSjTFgKu5CzpYI557+cWER5389fEA 75OV8zA/aXd+bAZ0ncaW/sv9jKxNB5ra8jfWhFkCAT6Gm0xmCZjdTOGS3 OAVPCCoXKby17miLoOkqG37VeOLHEcDI3du5L9rAAvidLxCS51RuQfD8E yFzpSr74WqkzJce2x5U6VwY/jxhCOCZfbKA0zSJZrKN7M2iAugIHkV5PY zQx0iv5UaGDZH7X2FgOCMErT6VxDE/bYSBM1T7ehWSF9719/JnrNT0szy bb04hkagR9IYQkUqDcRionqe9Z8LbmyzuqSZ28ITp8TapaqirOOsnPKLi A==; X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="383418456" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="383418456" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="1004134839" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="1004134839" From: Yuan Liu To: quintela@redhat.com, peterx@redhat.com, farosas@suse.de, leobras@redhat.com Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com Subject: [PATCH 1/5] configure: add qpl meson option Date: Thu, 19 Oct 2023 06:12:20 +0800 Message-Id: <20231018221224.599065-2-yuan1.liu@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231018221224.599065-1-yuan1.liu@intel.com> References: <20231018221224.599065-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=192.55.52.93; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_06_12=1.543, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 19 Oct 2023 09:38:19 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1697722967603100003 Content-Type: text/plain; charset="utf-8" Intel Query Processing Library (QPL) is an open-source library that supports features of the new Intel In-Memory Analytics Accelerator (IAA) available on Intel Xeon Sapphire Rapids processors, including high-throughput compression and decompression. add --enable-qpl and --disable-qpl options for data (de)compression using IAA during the live migration process. Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou --- meson.build | 9 ++++++++- meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 79aef19bdc..0a69bf68cf 100644 --- a/meson.build +++ b/meson.build @@ -1032,6 +1032,11 @@ if not get_option('zstd').auto() or have_block required: get_option('zstd'), method: 'pkg-config') endif +qpl =3D not_found +if not get_option('qpl').auto() + qpl =3D dependency('libqpl', required: get_option('qpl'), + method: 'pkg-config') +endif virgl =3D not_found =20 have_vhost_user_gpu =3D have_tools and targetos =3D=3D 'linux' and pixman.= found() @@ -2158,6 +2163,7 @@ config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc= _trim) config_host_data.set('CONFIG_STATX', has_statx) config_host_data.set('CONFIG_STATX_MNT_ID', has_statx_mnt_id) config_host_data.set('CONFIG_ZSTD', zstd.found()) +config_host_data.set('CONFIG_QPL', qpl.found()) config_host_data.set('CONFIG_FUSE', fuse.found()) config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found()) config_host_data.set('CONFIG_SPICE_PROTOCOL', spice_protocol.found()) @@ -3616,7 +3622,7 @@ libmigration =3D static_library('migration', sources:= migration_files + genh, name_suffix: 'fa', build_by_default: false) migration =3D declare_dependency(link_with: libmigration, - dependencies: [zlib, qom, io]) + dependencies: [zlib, qom, io, qpl]) system_ss.add(migration) =20 block_ss =3D block_ss.apply(config_targetos, strict: false) @@ -4281,6 +4287,7 @@ summary_info +=3D {'blkio support': blkio} summary_info +=3D {'curl support': curl} summary_info +=3D {'Multipath support': mpathpersist} summary_info +=3D {'Linux AIO support': libaio} +summary_info +=3D {'Query Processing Library support': qpl} summary_info +=3D {'Linux io_uring support': linux_io_uring} summary_info +=3D {'ATTR/XATTR support': libattr} summary_info +=3D {'RDMA support': rdma} diff --git a/meson_options.txt b/meson_options.txt index 6a17b90968..e8e7e37893 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -251,6 +251,8 @@ option('xkbcommon', type : 'feature', value : 'auto', description: 'xkbcommon support') option('zstd', type : 'feature', value : 'auto', description: 'zstd compression support') +option('qpl', type : 'feature', value : 'auto', + description: 'Query Processing Library support') option('fuse', type: 'feature', value: 'auto', description: 'FUSE block device export') option('fuse_lseek', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 2a74b0275b..e2adb13ce5 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -206,6 +206,7 @@ meson_options_help() { printf "%s\n" ' Xen PCI passthrough support' printf "%s\n" ' xkbcommon xkbcommon support' printf "%s\n" ' zstd zstd compression support' + printf "%s\n" ' qpl Query Processing Library support' } _meson_option_parse() { case $1 in @@ -417,6 +418,8 @@ _meson_option_parse() { --disable-qga-vss) printf "%s" -Dqga_vss=3Ddisabled ;; --enable-qom-cast-debug) printf "%s" -Dqom_cast_debug=3Dtrue ;; --disable-qom-cast-debug) printf "%s" -Dqom_cast_debug=3Dfalse ;; + --enable-qpl) printf "%s" -Dqpl=3Denabled ;; + --disable-qpl) printf "%s" -Dqpl=3Ddisabled ;; --enable-rbd) printf "%s" -Drbd=3Denabled ;; --disable-rbd) printf "%s" -Drbd=3Ddisabled ;; --enable-rdma) printf "%s" -Drdma=3Denabled ;; --=20 2.39.3 From nobody Wed Nov 27 18:43:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1697722756; cv=none; d=zohomail.com; s=zohoarc; b=AWRxtjclewilHXvW8WLRG0fZ4cwqjMpB3fblDB8Ca8/DHHVeoVYY2H1KxiFaYK/cUjfLQ3nfB1XqFg5lZRIOqOBbSYOnkmuIJV1Ntl2v86n0TI7hw5cv/luWzIQN4BAOg/5gJSXDm2yykEr+Ep9CS0SBtQ2oICfX1rVuMVnWbWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697722756; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iROTbLjzMq9K/uuKs7pJELd89y5b+MtO7/SaNyRac38=; b=Y77MRdchSUneW9Lg4+rUDVX17JOAzv1F8wpjmQsag8ppNU8yMGo1NPRtZx7UBUscXVKuYKXpECmY/1Zik8CpBbIYmPUh64QtSUSzOdRV1e/SJb6EHVrxAidQtAOHf/biueyGeDbnwfDiIVoFvv0TE4yv7Efyi9NSlg/3HPLmRsY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697722756439468.20673387247155; Thu, 19 Oct 2023 06:39:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtTEk-0000Hz-4k; Thu, 19 Oct 2023 09:38:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtNyj-0003Ae-9f for qemu-devel@nongnu.org; Thu, 19 Oct 2023 04:02:02 -0400 Received: from mgamail.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtNyg-0006LE-Qi for qemu-devel@nongnu.org; Thu, 19 Oct 2023 04:02:00 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 01:01:57 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by fmsmga006.fm.intel.com with ESMTP; 19 Oct 2023 01:01:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697702518; x=1729238518; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZhQKN7EFGxpu5IEr8DgBFIeEvHbuo5TQ3WYoPPCFuqM=; b=hKtEcQbKZkI+uam+MRG+ua0cePW3Kk5yFsHC8+SDKgK+S4k2xUM6R2KJ lMVDHhgo1iFYYBby/195jCCAlhulkV4frsoexSq25szr70M6JxcYVlef7 PVeCIO9m+Hi9YjPZphp6u33Hxw7qDtdJFAj1CMDyMMCrde23iCt+0Bz4I RgJIBtFvCNqucp8xtzMp+/JHkIN2XB6//oYtOqkdJ7UVnajbxkbs4Wz9u KKtFcInFhOCemupbFcglmsORqtX8U2eUMoiEg9MkSzdGCrxzOVA6YBS/z VYgDpnz5gbupz1yYvRyimH5DKD9GiQDFCPsKaeFTEK1oclMMwYpNGG/fU Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="383418471" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="383418471" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="1004134848" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="1004134848" From: Yuan Liu To: quintela@redhat.com, peterx@redhat.com, farosas@suse.de, leobras@redhat.com Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com Subject: [PATCH 2/5] qapi/migration: Introduce compress-with-iaa migration parameter Date: Thu, 19 Oct 2023 06:12:21 +0800 Message-Id: <20231018221224.599065-3-yuan1.liu@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231018221224.599065-1-yuan1.liu@intel.com> References: <20231018221224.599065-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=192.55.52.93; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_06_12=1.543, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 19 Oct 2023 09:38:36 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1697722758802100011 Content-Type: text/plain; charset="utf-8" Introduce the compress-with-iaa=3Don/off option to enable or disable live migration data (de)compression with the In-Memory Analytics Accelerator (IAA). The data (de)compression with IAA feature is based on the migration compression capability, which is enabled by setting migrate_set_capability compress on. If the migration compression capability is enabled and the IAA compression parameter is set, IAA will be used instead of CPU for data (de)compression. Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou --- migration/migration-hmp-cmds.c | 8 ++++++++ migration/options.c | 20 ++++++++++++++++++++ migration/options.h | 1 + qapi/migration.json | 4 +++- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index c115ef2d23..38e441bb37 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -281,6 +281,10 @@ void hmp_info_migrate_parameters(Monitor *mon, const Q= Dict *qdict) monitor_printf(mon, "%s: %u\n", MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_THREADS), params->compress_threads); + assert(params->has_compress_with_iaa); + monitor_printf(mon, "%s: %s\n", + MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_WITH_IAA), + params->compress_with_iaa ? "on" : "off"); assert(params->has_compress_wait_thread); monitor_printf(mon, "%s: %s\n", MigrationParameter_str(MIGRATION_PARAMETER_COMPRESS_WAIT_THREA= D), @@ -517,6 +521,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDi= ct *qdict) p->has_compress_threads =3D true; visit_type_uint8(v, param, &p->compress_threads, &err); break; + case MIGRATION_PARAMETER_COMPRESS_WITH_IAA: + p->has_compress_with_iaa =3D true; + visit_type_bool(v, param, &p->compress_with_iaa, &err); + break; case MIGRATION_PARAMETER_COMPRESS_WAIT_THREAD: p->has_compress_wait_thread =3D true; visit_type_bool(v, param, &p->compress_wait_thread, &err); diff --git a/migration/options.c b/migration/options.c index 1d1e1321b0..06d4b36b77 100644 --- a/migration/options.c +++ b/migration/options.c @@ -107,6 +107,8 @@ Property migration_properties[] =3D { DEFINE_PROP_UINT8("x-compress-threads", MigrationState, parameters.compress_threads, DEFAULT_MIGRATE_COMPRESS_THREAD_COUNT), + DEFINE_PROP_BOOL("x-compress-with-iaa", MigrationState, + parameters.compress_with_iaa, false), DEFINE_PROP_BOOL("x-compress-wait-thread", MigrationState, parameters.compress_wait_thread, true), DEFINE_PROP_UINT8("x-decompress-threads", MigrationState, @@ -724,6 +726,13 @@ int migrate_compress_threads(void) return s->parameters.compress_threads; } =20 +bool migrate_compress_with_iaa(void) +{ + MigrationState *s =3D migrate_get_current(); + + return s->parameters.compress_with_iaa; +} + int migrate_compress_wait_thread(void) { MigrationState *s =3D migrate_get_current(); @@ -899,6 +908,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->compress_level =3D s->parameters.compress_level; params->has_compress_threads =3D true; params->compress_threads =3D s->parameters.compress_threads; + params->has_compress_with_iaa =3D true; + params->compress_with_iaa =3D s->parameters.compress_with_iaa; params->has_compress_wait_thread =3D true; params->compress_wait_thread =3D s->parameters.compress_wait_thread; params->has_decompress_threads =3D true; @@ -969,6 +980,7 @@ void migrate_params_init(MigrationParameters *params) /* Set has_* up only for parameter checks */ params->has_compress_level =3D true; params->has_compress_threads =3D true; + params->has_compress_with_iaa =3D true; params->has_compress_wait_thread =3D true; params->has_decompress_threads =3D true; params->has_throttle_trigger_threshold =3D true; @@ -1195,6 +1207,10 @@ static void migrate_params_test_apply(MigrateSetPara= meters *params, dest->decompress_threads =3D params->decompress_threads; } =20 + if (params->has_compress_with_iaa) { + dest->compress_with_iaa =3D params->compress_with_iaa; + } + if (params->has_throttle_trigger_threshold) { dest->throttle_trigger_threshold =3D params->throttle_trigger_thre= shold; } @@ -1300,6 +1316,10 @@ static void migrate_params_apply(MigrateSetParameter= s *params, Error **errp) s->parameters.decompress_threads =3D params->decompress_threads; } =20 + if (params->has_compress_with_iaa) { + s->parameters.compress_with_iaa =3D params->compress_with_iaa; + } + if (params->has_throttle_trigger_threshold) { s->parameters.throttle_trigger_threshold =3D params->throttle_trig= ger_threshold; } diff --git a/migration/options.h b/migration/options.h index 045e2a41a2..926d723d0e 100644 --- a/migration/options.h +++ b/migration/options.h @@ -77,6 +77,7 @@ uint8_t migrate_cpu_throttle_increment(void); uint8_t migrate_cpu_throttle_initial(void); bool migrate_cpu_throttle_tailslow(void); int migrate_decompress_threads(void); +bool migrate_compress_with_iaa(void); uint64_t migrate_downtime_limit(void); uint8_t migrate_max_cpu_throttle(void); uint64_t migrate_max_bandwidth(void); diff --git a/qapi/migration.json b/qapi/migration.json index 8843e74b59..8edc622dd9 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -835,7 +835,7 @@ { 'enum': 'MigrationParameter', 'data': ['announce-initial', 'announce-max', 'announce-rounds', 'announce-step', - 'compress-level', 'compress-threads', 'decompress-threads', + 'compress-level', 'compress-threads', 'compress-with-iaa', 'dec= ompress-threads', 'compress-wait-thread', 'throttle-trigger-threshold', 'cpu-throttle-initial', 'cpu-throttle-increment', 'cpu-throttle-tailslow', @@ -1008,6 +1008,7 @@ '*announce-step': 'size', '*compress-level': 'uint8', '*compress-threads': 'uint8', + '*compress-with-iaa': 'bool', '*compress-wait-thread': 'bool', '*decompress-threads': 'uint8', '*throttle-trigger-threshold': 'uint8', @@ -1208,6 +1209,7 @@ '*announce-step': 'size', '*compress-level': 'uint8', '*compress-threads': 'uint8', + '*compress-with-iaa': 'bool', '*compress-wait-thread': 'bool', '*decompress-threads': 'uint8', '*throttle-trigger-threshold': 'uint8', --=20 2.39.3 From nobody Wed Nov 27 18:43:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1697722838; cv=none; d=zohomail.com; s=zohoarc; b=XE8f5tB5xOob2HTMq0fDv74XQBy3AvaENqyC+KLtUwjxASreR2kOoicYW455wkXem9g5cv2nZn0wG8sw9thhRsdjlnw93jdRoDP9GwCQiVK3/aZxVhGVfnjToaesNPAPYOHIB7jTFUorGUpzOwJ/8nnjABZfDaBnVHwTyzRW5TE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697722838; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=B5WKTLGR0C/mdRljHvjNKTqcCmvmCfBKWla0g4eitfg=; b=Ke5YKrL2VprU8YehKzkZAK9/+RgYoJ6P4drC4ypborqYmzc1f3nd6o4mMUfOVhorCJH1vIWRfLL7Y55xcZ1GB0I1kqiOVUGRQb4VOzl7yNxqImT2KckcHqJY331nBkn3jP/Xx4XgyOEGbFUWxqptaa9740DAREOqST14Etoemes= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697722838628960.4531156498763; Thu, 19 Oct 2023 06:40:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtTF0-0001Cd-Jz; Thu, 19 Oct 2023 09:39:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtNyn-0003BP-2u for qemu-devel@nongnu.org; Thu, 19 Oct 2023 04:02:06 -0400 Received: from mgamail.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtNyk-0006MG-OX for qemu-devel@nongnu.org; Thu, 19 Oct 2023 04:02:04 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 01:01:59 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by fmsmga006.fm.intel.com with ESMTP; 19 Oct 2023 01:01:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697702522; x=1729238522; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DROmFsTvSKbYJNdAP2qUwrPECgNR/OTTq/y6dYy22uI=; b=LtdJ7MIAulyyKE5NlsAqtg1EGTyZ42SirzjQdZDlR41AZQ7VAodHCsvR vBfZ8Ht3wYag4MnJi59wilfsiOZf6QYRKwqFfWZHqNqPNRRfVyl2smZI5 fKEeglQ+yI1zjjOJV9balKSpV+R0iISMdiV954m52Z5T/I1q2I/ANiMb0 QCZJPpXwyEvbN1A63UpzncM31o8LdT5WoYGkdCYwyWD9f6QduLv5bmoB+ 3rW0lLadGBClrCy7zuLmx4JrkR6Ca+tlfEkv4+e7maZD+cRqFowX6CjL2 zJssGnrB+rVX7+v6uvlY0ocrtDJHmSIJF63eTGA8C4cFD8G8OaSz59WZs A==; X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="383418479" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="383418479" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="1004134854" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="1004134854" From: Yuan Liu To: quintela@redhat.com, peterx@redhat.com, farosas@suse.de, leobras@redhat.com Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com Subject: [PATCH 3/5] ram compress: Refactor ram compression functions Date: Thu, 19 Oct 2023 06:12:22 +0800 Message-Id: <20231018221224.599065-4-yuan1.liu@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231018221224.599065-1-yuan1.liu@intel.com> References: <20231018221224.599065-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=192.55.52.93; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_06_12=1.543, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 19 Oct 2023 09:38:26 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1697722839005100009 Content-Type: text/plain; charset="utf-8" Refactor legacy RAM compression functions to support both IAA compression and CPU compression. Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou --- migration/migration.c | 6 +-- migration/ram-compress.c | 81 ++++++++++++++++++++++++++++++++-------- migration/ram-compress.h | 10 ++--- migration/ram.c | 18 ++++++--- 4 files changed, 86 insertions(+), 29 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 585d3c8f55..08a9c313d0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -237,7 +237,7 @@ void migration_incoming_state_destroy(void) struct MigrationIncomingState *mis =3D migration_incoming_get_current(= ); =20 multifd_load_cleanup(); - compress_threads_load_cleanup(); + ram_compress_load_cleanup(); =20 if (mis->to_src_file) { /* Tell source that we are done */ @@ -524,7 +524,7 @@ process_incoming_migration_co(void *opaque) =20 assert(mis->from_src_file); =20 - if (compress_threads_load_setup(mis->from_src_file)) { + if (ram_compress_load_setup(mis->from_src_file)) { error_report("Failed to setup decompress threads"); goto fail; } @@ -577,7 +577,7 @@ fail: qemu_fclose(mis->from_src_file); =20 multifd_load_cleanup(); - compress_threads_load_cleanup(); + ram_compress_load_cleanup(); =20 exit(EXIT_FAILURE); } diff --git a/migration/ram-compress.c b/migration/ram-compress.c index 06254d8c69..47357352f7 100644 --- a/migration/ram-compress.c +++ b/migration/ram-compress.c @@ -105,11 +105,11 @@ static void *do_data_compress(void *opaque) return NULL; } =20 -void compress_threads_save_cleanup(void) +static void compress_threads_save_cleanup(void) { int i, thread_count; =20 - if (!migrate_compress() || !comp_param) { + if (!comp_param) { return; } =20 @@ -144,13 +144,10 @@ void compress_threads_save_cleanup(void) comp_param =3D NULL; } =20 -int compress_threads_save_setup(void) +static int compress_threads_save_setup(void) { int i, thread_count; =20 - if (!migrate_compress()) { - return 0; - } thread_count =3D migrate_compress_threads(); compress_threads =3D g_new0(QemuThread, thread_count); comp_param =3D g_new0(CompressParam, thread_count); @@ -370,6 +367,11 @@ int wait_for_decompress_done(void) return 0; } =20 + if (migrate_compress_with_iaa()) { + /* Implement in next patch */ + return 0; + } + thread_count =3D migrate_decompress_threads(); qemu_mutex_lock(&decomp_done_lock); for (idx =3D 0; idx < thread_count; idx++) { @@ -381,13 +383,10 @@ int wait_for_decompress_done(void) return qemu_file_get_error(decomp_file); } =20 -void compress_threads_load_cleanup(void) +static void compress_threads_load_cleanup(void) { int i, thread_count; =20 - if (!migrate_compress()) { - return; - } thread_count =3D migrate_decompress_threads(); for (i =3D 0; i < thread_count; i++) { /* @@ -422,14 +421,10 @@ void compress_threads_load_cleanup(void) decomp_file =3D NULL; } =20 -int compress_threads_load_setup(QEMUFile *f) +static int compress_threads_load_setup(QEMUFile *f) { int i, thread_count; =20 - if (!migrate_compress()) { - return 0; - } - thread_count =3D migrate_decompress_threads(); decompress_threads =3D g_new0(QemuThread, thread_count); decomp_param =3D g_new0(DecompressParam, thread_count); @@ -457,7 +452,7 @@ exit: return -1; } =20 -void decompress_data_with_multi_threads(QEMUFile *f, void *host, int len) +static void decompress_data_with_multi_threads(QEMUFile *f, void *host, in= t len) { int idx, thread_count; =20 @@ -483,3 +478,57 @@ void decompress_data_with_multi_threads(QEMUFile *f, v= oid *host, int len) } } } + +int ram_compress_save_setup(void) +{ + if (!migrate_compress()) { + return 0; + } + if (migrate_compress_with_iaa()) { + /* Implement in next patch */ + return 0; + } + return compress_threads_save_setup(); +} + +void ram_compress_save_cleanup(void) +{ + if (!migrate_compress()) { + return; + } + if (migrate_compress_with_iaa()) { + /* Implement in next patch */ + return; + } + compress_threads_save_cleanup(); +} + +void ram_decompress_data(QEMUFile *f, void *host, int len) +{ + if (migrate_compress_with_iaa()) { + /* Implement in next patch */ + } + decompress_data_with_multi_threads(f, host, len); +} + +int ram_compress_load_setup(QEMUFile *f) +{ + if (!migrate_compress()) { + return 0; + } + if (migrate_compress_with_iaa()) { + /* Implement in next patch */ + } + return compress_threads_load_setup(f); +} + +void ram_compress_load_cleanup(void) +{ + if (!migrate_compress()) { + return; + } + if (migrate_compress_with_iaa()) { + /* Implement in next patch */ + } + compress_threads_load_cleanup(); +} diff --git a/migration/ram-compress.h b/migration/ram-compress.h index 6f7fe2f472..382083acf6 100644 --- a/migration/ram-compress.h +++ b/migration/ram-compress.h @@ -55,16 +55,16 @@ struct CompressParam { }; typedef struct CompressParam CompressParam; =20 -void compress_threads_save_cleanup(void); -int compress_threads_save_setup(void); +void ram_compress_save_cleanup(void); +int ram_compress_save_setup(void); =20 void flush_compressed_data(int (send_queued_data(CompressParam *))); int compress_page_with_multi_thread(RAMBlock *block, ram_addr_t offset, int (send_queued_data(CompressParam *))); =20 int wait_for_decompress_done(void); -void compress_threads_load_cleanup(void); -int compress_threads_load_setup(QEMUFile *f); -void decompress_data_with_multi_threads(QEMUFile *f, void *host, int len); +void ram_compress_load_cleanup(void); +int ram_compress_load_setup(QEMUFile *f); +void ram_decompress_data(QEMUFile *f, void *host, int len); =20 #endif diff --git a/migration/ram.c b/migration/ram.c index e4bfd39f08..34ee1de332 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1347,6 +1347,10 @@ static void ram_flush_compressed_data(RAMState *rs) if (!save_page_use_compression(rs)) { return; } + if (migrate_compress_with_iaa()) { + /* Implement in next patch */ + return; + } =20 flush_compressed_data(send_queued_data); } @@ -2099,6 +2103,10 @@ static bool save_compress_page(RAMState *rs, PageSea= rchStatus *pss, return false; } =20 + if (migrate_compress_with_iaa()) { + /* Implement in next patch */ + return true; + } if (compress_page_with_multi_thread(block, offset, send_queued_data) >= 0) { return true; } @@ -2498,7 +2506,7 @@ static void ram_save_cleanup(void *opaque) } =20 xbzrle_cleanup(); - compress_threads_save_cleanup(); + ram_compress_save_cleanup(); ram_state_cleanup(rsp); g_free(migration_ops); migration_ops =3D NULL; @@ -3023,14 +3031,14 @@ static int ram_save_setup(QEMUFile *f, void *opaque) RAMBlock *block; int ret; =20 - if (compress_threads_save_setup()) { + if (ram_compress_save_setup()) { return -1; } =20 /* migration has already setup the bitmap, reuse it. */ if (!migration_in_colo_state()) { if (ram_init_all(rsp) !=3D 0) { - compress_threads_save_cleanup(); + ram_compress_save_cleanup(); return -1; } } @@ -3753,7 +3761,7 @@ int ram_load_postcopy(QEMUFile *f, int channel) ret =3D -EINVAL; break; } - decompress_data_with_multi_threads(f, page_buffer, len); + ram_decompress_data(f, page_buffer, len); break; case RAM_SAVE_FLAG_MULTIFD_FLUSH: multifd_recv_sync_main(); @@ -4022,7 +4030,7 @@ static int ram_load_precopy(QEMUFile *f) ret =3D -EINVAL; break; } - decompress_data_with_multi_threads(f, host, len); + ram_decompress_data(f, host, len); break; =20 case RAM_SAVE_FLAG_XBZRLE: --=20 2.39.3 From nobody Wed Nov 27 18:43:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1697722838; cv=none; d=zohomail.com; s=zohoarc; b=HJoWF+SuwcpmuTNMLNbyOsJiPbR5cK2BITqe8EUH5ar1iiAM4IiwQDLN+sJnWtxn61lrbu8PjviWd3A4F6TfeGjgQTIizx9uX5BXjRFda/KYU6Bq6KgaZy/Bq1kdKB1kwofFKZ9rqciDo70f9JlfGzh08qgp1NREKitOz2bHaQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697722838; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RAQ8eX33T0C055i5QdgUszdtKPCz1DK+9mp5MQJu6to=; b=JnPygIO42X2/MDo2/SlCdaDfaxoXo5sfwWsQJt5++XLKtzABaUeA9Icu7sQz3Ex2JVT6xd44drv9OHJaix+1TlEEa5iFJ1fMyx4/TaIp7Mxfrj3wQ4bgG5IXkUvGcAg1M0vGRWSzA+7wWuilsRmqPJZM8+OCGbEKXbGj6iQPObg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169772283870573.1914620008597; Thu, 19 Oct 2023 06:40:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtTEt-0000jB-Oj; Thu, 19 Oct 2023 09:39:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtNyo-0003BS-Qr for qemu-devel@nongnu.org; Thu, 19 Oct 2023 04:02:08 -0400 Received: from mgamail.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtNym-0006MN-Ip for qemu-devel@nongnu.org; Thu, 19 Oct 2023 04:02:06 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 01:02:02 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by fmsmga006.fm.intel.com with ESMTP; 19 Oct 2023 01:02:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697702524; x=1729238524; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wZYxJmWSfUug2p3jTY5+EH28LA+GLCN7OAdwgFeYHKU=; b=Cu4D4HLpI/WkweN+SJCBOctGynhfnz9ndiKlCJjGCiGawAWA/5EKE7ug bqQ7bXQSeVMvP8Bhhqrul8ifiYjmg9Pte09L3gJcvF7TPa6fLFVocUM2u 49f5YxvWaIXhK1L5il6YUfT7pud3IffOKSNlruceYC3W1JQE4U+U092U7 5OpOIt3MxIJZERofoahF5g1xA0aY7myqsrfnQ5TWglOEb8cd/ZEHAVkkn h/DauI8nHSQvKX5W6KmIErIhZvbgI9LEznEaGVc5loqe/tOqWC+Jdk+QW /DTZWZdHDO94HG1RNYg9DI40voZLnzm9ljMmQQwTGz3IEq+50JPixwI9n g==; X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="383418488" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="383418488" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="1004134861" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="1004134861" From: Yuan Liu To: quintela@redhat.com, peterx@redhat.com, farosas@suse.de, leobras@redhat.com Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com Subject: [PATCH 4/5] migration iaa-compress: Add IAA initialization and deinitialization Date: Thu, 19 Oct 2023 06:12:23 +0800 Message-Id: <20231018221224.599065-5-yuan1.liu@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231018221224.599065-1-yuan1.liu@intel.com> References: <20231018221224.599065-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=192.55.52.93; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_06_12=1.543, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 19 Oct 2023 09:38:37 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1697722840996100024 Content-Type: text/plain; charset="utf-8" This patch defines the structure for IAA jobs related to data compression and decompression, as well as the initialization and deinitialization processes for IAA. Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou --- migration/iaa-ram-compress.c | 152 +++++++++++++++++++++++++++++++++++ migration/iaa-ram-compress.h | 20 +++++ migration/meson.build | 1 + migration/ram-compress.c | 21 +++-- 4 files changed, 189 insertions(+), 5 deletions(-) create mode 100644 migration/iaa-ram-compress.c create mode 100644 migration/iaa-ram-compress.h diff --git a/migration/iaa-ram-compress.c b/migration/iaa-ram-compress.c new file mode 100644 index 0000000000..da45952594 --- /dev/null +++ b/migration/iaa-ram-compress.c @@ -0,0 +1,152 @@ +/* + * QEMU IAA compression support + * + * Copyright (c) 2023 Intel Corporation + * Written by: + * Yuan Liu + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "qemu/error-report.h" +#include "migration.h" +#include "options.h" +#include "io/channel-null.h" +#include "exec/target_page.h" +#include "exec/ramblock.h" +#include "iaa-ram-compress.h" +#include "qpl/qpl.h" + +/* The IAA work queue maximum depth */ +#define IAA_JOB_NUM (512) + +typedef struct { + CompressResult result; + ram_addr_t offset; /* The offset of the compressed page in the block */ + RAMBlock *block; /* The block of the compressed page */ +} iaa_comp_param; + +typedef struct { + uint8_t *host; /* Target address for decompression page */ +} iaa_decomp_param; + +typedef struct IaaJob { + QSIMPLEQ_ENTRY(IaaJob) entry; + bool is_compression; + uint32_t in_len; + uint32_t out_len; + uint8_t *in_buf; + uint8_t *out_buf; + qpl_job *qpl; /* It is used to submit (de)compression work to IAA */ + union { + iaa_comp_param comp; + iaa_decomp_param decomp; + } param; +} IaaJob; + +typedef struct IaaJobPool { + uint32_t pos; + uint32_t cnt; + IaaJob *jobs[IAA_JOB_NUM]; + uint8_t *job_in_buf; /* The IAA device input buffers for all IAA jobs = */ + uint8_t *job_out_buf; /* The IAA device output buffers for all IAA job= s */ + size_t buf_size; +} IaaJobPool; + +static IaaJobPool iaa_job_pool; +/* This is used to record jobs that have been submitted but not yet comple= ted */ +static QSIMPLEQ_HEAD(, IaaJob) polling_queue =3D + QSIMPLEQ_HEAD_INITIALIZER(polling_queue= ); + +void iaa_compress_deinit(void) +{ + for (int i =3D 0; i < IAA_JOB_NUM; i++) { + if (iaa_job_pool.jobs[i]) { + if (iaa_job_pool.jobs[i]->qpl) { + qpl_fini_job(iaa_job_pool.jobs[i]->qpl); + g_free(iaa_job_pool.jobs[i]->qpl); + } + g_free(iaa_job_pool.jobs[i]); + } + } + if (iaa_job_pool.job_in_buf) { + munmap(iaa_job_pool.job_in_buf, iaa_job_pool.buf_size); + iaa_job_pool.job_in_buf =3D NULL; + } + if (iaa_job_pool.job_out_buf) { + munmap(iaa_job_pool.job_out_buf, iaa_job_pool.buf_size); + iaa_job_pool.job_out_buf =3D NULL; + } +} + +int iaa_compress_init(bool is_decompression) +{ + qpl_status status; + IaaJob *job =3D NULL; + uint32_t qpl_hw_size =3D 0; + int flags =3D MAP_PRIVATE | MAP_POPULATE | MAP_ANONYMOUS; + size_t buf_size =3D IAA_JOB_NUM * qemu_target_page_size(); + + QSIMPLEQ_INIT(&polling_queue); + memset(&iaa_job_pool, 0, sizeof(IaaJobPool)); + iaa_job_pool.buf_size =3D buf_size; + iaa_job_pool.job_out_buf =3D mmap(NULL, buf_size, PROT_READ | PROT_WRI= TE, + flags, -1, 0); + if (iaa_job_pool.job_out_buf =3D=3D MAP_FAILED) { + error_report("Failed to allocate iaa output buffer, error %s", + strerror(errno)); + return -1; + } + /* + * There is no need to allocate an input buffer for the compression + * function, the IAA hardware can directly access the virtual machine + * memory through the host address through Share Virtual Memory(SVM) + */ + if (is_decompression) { + iaa_job_pool.job_in_buf =3D mmap(NULL, buf_size, PROT_READ | PROT_= WRITE, + flags, -1, 0); + if (iaa_job_pool.job_in_buf =3D=3D MAP_FAILED) { + error_report("Failed to allocate iaa input buffer, error %s", + strerror(errno)); + goto init_err; + } + } + status =3D qpl_get_job_size(qpl_path_hardware, &qpl_hw_size); + if (status !=3D QPL_STS_OK) { + error_report("Failed to initialize iaa hardware, error %d", status= ); + goto init_err; + } + for (int i =3D 0; i < IAA_JOB_NUM; i++) { + size_t buf_offset =3D qemu_target_page_size() * i; + job =3D g_try_malloc0(sizeof(IaaJob)); + if (!job) { + error_report("Failed to allocate iaa job memory, error %s", + strerror(errno)); + goto init_err; + } + iaa_job_pool.jobs[i] =3D job; + job->qpl =3D g_try_malloc0(qpl_hw_size); + if (!job->qpl) { + error_report("Failed to allocate iaa qpl memory, error %s", + strerror(errno)); + goto init_err; + } + if (is_decompression) { + job->in_buf =3D iaa_job_pool.job_in_buf + buf_offset; + } + job->out_buf =3D iaa_job_pool.job_out_buf + buf_offset; + status =3D qpl_init_job(qpl_path_hardware, job->qpl); + if (status !=3D QPL_STS_OK) { + error_report("Failed to initialize iaa qpl, error %d", status); + goto init_err; + } + } + return 0; +init_err: + iaa_compress_deinit(); + return -1; +} diff --git a/migration/iaa-ram-compress.h b/migration/iaa-ram-compress.h new file mode 100644 index 0000000000..27998b255b --- /dev/null +++ b/migration/iaa-ram-compress.h @@ -0,0 +1,20 @@ +/* + * QEMU IAA compression support + * + * Copyright (c) 2023 Intel Corporation + * Written by: + * Yuan Liu + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_MIGRATION_IAA_COMPRESS_H +#define QEMU_MIGRATION_IAA_COMPRESS_H +#include "qemu-file.h" +#include "ram-compress.h" + +int iaa_compress_init(bool is_decompression); +void iaa_compress_deinit(void); +#endif diff --git a/migration/meson.build b/migration/meson.build index 92b1cc4297..9131815420 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -40,6 +40,7 @@ if get_option('live_block_migration').allowed() system_ss.add(files('block.c')) endif system_ss.add(when: zstd, if_true: files('multifd-zstd.c')) +system_ss.add(when: qpl, if_true: files('iaa-ram-compress.c')) =20 specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: files('ram.c', diff --git a/migration/ram-compress.c b/migration/ram-compress.c index 47357352f7..acc511ce57 100644 --- a/migration/ram-compress.c +++ b/migration/ram-compress.c @@ -30,6 +30,9 @@ #include "qemu/cutils.h" =20 #include "ram-compress.h" +#ifdef CONFIG_QPL +#include "iaa-ram-compress.h" +#endif =20 #include "qemu/error-report.h" #include "migration.h" @@ -484,10 +487,11 @@ int ram_compress_save_setup(void) if (!migrate_compress()) { return 0; } +#ifdef CONFIG_QPL if (migrate_compress_with_iaa()) { - /* Implement in next patch */ - return 0; + return iaa_compress_init(false); } +#endif return compress_threads_save_setup(); } =20 @@ -496,10 +500,12 @@ void ram_compress_save_cleanup(void) if (!migrate_compress()) { return; } +#ifdef CONFIG_QPL if (migrate_compress_with_iaa()) { - /* Implement in next patch */ + iaa_compress_deinit(); return; } +#endif compress_threads_save_cleanup(); } =20 @@ -516,9 +522,11 @@ int ram_compress_load_setup(QEMUFile *f) if (!migrate_compress()) { return 0; } +#ifdef CONFIG_QPL if (migrate_compress_with_iaa()) { - /* Implement in next patch */ + return iaa_compress_init(true); } +#endif return compress_threads_load_setup(f); } =20 @@ -527,8 +535,11 @@ void ram_compress_load_cleanup(void) if (!migrate_compress()) { return; } +#ifdef CONFIG_QPL if (migrate_compress_with_iaa()) { - /* Implement in next patch */ + iaa_compress_deinit(); + return; } +#endif compress_threads_load_cleanup(); } --=20 2.39.3 From nobody Wed Nov 27 18:43:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1697722927; cv=none; d=zohomail.com; s=zohoarc; b=NiInwxSaVW4MXkKF05iJ2uXiHNnFkIN3/ygnxZJroPBGlYU3GH5CUtLazOUsnGxkM3/MZ3X0y7zZY+CGrKYovugmVN+oN4V39Qoz+sNWysOPWkHgxadBOSrZ8IkraJR8kPRW82nzxHEh2NLGn0voaAwgM+bx0XXRtafB59UXgnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697722927; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Bhg+aRqBPzE/yWE97bl8DJ0GuoBpEBDWF+tFJPh3Bhg=; b=X7+mD5uG5/0o3jRqq1usuDLpdxPlkwKvpJP3EITEevqWGUQyWjlAkEWrR5pECZ7nLAFpGv+3T25dg/TCErc2ER7bg/FRrIlvuJwTuqeuTLYChtgbgEvBZrPwK/pmg9f0jYoN2bf4+9eq7U/6JOKPMwps6sixOSH330ittgPr/zU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697722927824622.630482086401; Thu, 19 Oct 2023 06:42:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtTF5-0001uB-5c; Thu, 19 Oct 2023 09:39:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtNyx-0003FI-3G for qemu-devel@nongnu.org; Thu, 19 Oct 2023 04:02:15 -0400 Received: from mgamail.intel.com ([192.55.52.93]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtNyu-0006N8-SX for qemu-devel@nongnu.org; Thu, 19 Oct 2023 04:02:14 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Oct 2023 01:02:11 -0700 Received: from sae-gw02.sh.intel.com (HELO localhost) ([10.239.45.110]) by fmsmga006.fm.intel.com with ESMTP; 19 Oct 2023 01:02:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697702532; x=1729238532; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TFLaIokBr3NS3B84d8PU4bnFn7b2kvq59OhP5EiNt2U=; b=Q3Ymo2NegoI/DwMszjrzxoitkRJdQoeFyQ5rBwd4AhnABzy528MTo5OK b5VQTuwsCEUFuiuHMkI2UmWv7SgKz1iuM4w1S9okchhseqqmh50r60zhS ai2BHur+DRNBVJTA4qwDoGn0Z+CVUIaY6HHswDNcqSvqlLTpMpdcjukAx v9zmxjzjHpN/kw0fDBMmGYedEjmrAR7MNMzIQ0iVAW5U9DDTbWLEUfMOH FOQwR2B8Wk5wBlRZCaLVr9ZkrmPPB+a1s4L57jqjYXK77ARvtUfN9fh4U RmkE0OzfpyKUpvuZXfI7s1MkH25dt0yssq8vr1stqQYoAbTDXSoyKeQUu Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="383418517" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="383418517" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="1004134875" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="1004134875" From: Yuan Liu To: quintela@redhat.com, peterx@redhat.com, farosas@suse.de, leobras@redhat.com Cc: qemu-devel@nongnu.org, yuan1.liu@intel.com, nanhai.zou@intel.com Subject: [PATCH 5/5] migration iaa-compress: Implement IAA compression Date: Thu, 19 Oct 2023 06:12:24 +0800 Message-Id: <20231018221224.599065-6-yuan1.liu@intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231018221224.599065-1-yuan1.liu@intel.com> References: <20231018221224.599065-1-yuan1.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=192.55.52.93; envelope-from=yuan1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_06_12=1.543, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 19 Oct 2023 09:38:37 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1697722929437100003 Content-Type: text/plain; charset="utf-8" Implement the functions of IAA for data compression and decompression. The implementation uses non-blocking job submission and polling to check the job completion status to reduce IAA's overhead in the live migration process. Signed-off-by: Yuan Liu Reviewed-by: Nanhai Zou --- migration/iaa-ram-compress.c | 167 +++++++++++++++++++++++++++++++++++ migration/iaa-ram-compress.h | 7 ++ migration/ram-compress.c | 10 ++- migration/ram.c | 56 ++++++++++-- 4 files changed, 232 insertions(+), 8 deletions(-) diff --git a/migration/iaa-ram-compress.c b/migration/iaa-ram-compress.c index da45952594..243aeb6d55 100644 --- a/migration/iaa-ram-compress.c +++ b/migration/iaa-ram-compress.c @@ -12,6 +12,7 @@ =20 #include "qemu/osdep.h" #include "qemu/cutils.h" + #include "qemu/error-report.h" #include "migration.h" #include "options.h" @@ -62,6 +63,31 @@ static IaaJobPool iaa_job_pool; static QSIMPLEQ_HEAD(, IaaJob) polling_queue =3D QSIMPLEQ_HEAD_INITIALIZER(polling_queue= ); =20 +static IaaJob *get_job(send_iaa_data send_page) +{ + IaaJob *job; + +retry: + /* Wait for a job to complete when there is no available job */ + if (iaa_job_pool.cnt =3D=3D IAA_JOB_NUM) { + flush_iaa_jobs(false, send_page); + goto retry; + } + job =3D iaa_job_pool.jobs[iaa_job_pool.pos]; + iaa_job_pool.pos++; + iaa_job_pool.cnt++; + if (iaa_job_pool.pos =3D=3D IAA_JOB_NUM) { + iaa_job_pool.pos =3D 0; + } + return job; +} + +static void put_job(IaaJob *job) +{ + assert(iaa_job_pool.cnt > 0); + iaa_job_pool.cnt--; +} + void iaa_compress_deinit(void) { for (int i =3D 0; i < IAA_JOB_NUM; i++) { @@ -150,3 +176,144 @@ init_err: iaa_compress_deinit(); return -1; } + +static void process_completed_job(IaaJob *job, send_iaa_data send_page) +{ + if (job->is_compression) { + send_page(job->param.comp.block, job->param.comp.offset, + job->out_buf, job->out_len, job->param.comp.result); + } else { + assert(job->out_len =3D=3D qemu_target_page_size()); + memcpy(job->param.decomp.host, job->out_buf, job->out_len); + } + put_job(job); +} + +static qpl_status check_job_status(IaaJob *job, bool block) +{ + qpl_status status; + qpl_job *qpl =3D job->qpl; + + status =3D block ? qpl_wait_job(qpl) : qpl_check_job(qpl); + if (status =3D=3D QPL_STS_OK) { + job->out_len =3D qpl->total_out; + if (job->is_compression) { + job->param.comp.result =3D RES_COMPRESS; + /* if no compression benefit, send a normal page for migration= */ + if (job->out_len =3D=3D qemu_target_page_size()) { + iaa_comp_param *param =3D &(job->param.comp); + memcpy(job->out_buf, (param->block->host + param->offset), + job->out_len); + job->param.comp.result =3D RES_NONE; + } + } + } else if (status =3D=3D QPL_STS_MORE_OUTPUT_NEEDED) { + if (job->is_compression) { + /* + * if the compressed data is larger than the original data, se= nd a + * normal page for migration, in this case, IAA has copied the + * original data to job->out_buf automatically. + */ + job->out_len =3D qemu_target_page_size(); + job->param.comp.result =3D RES_NONE; + status =3D QPL_STS_OK; + } + } + return status; +} + +static void check_polling_jobs(send_iaa_data send_page) +{ + IaaJob *job, *job_next; + qpl_status status; + + QSIMPLEQ_FOREACH_SAFE(job, &polling_queue, entry, job_next) { + status =3D check_job_status(job, false); + if (status =3D=3D QPL_STS_OK) { /* job has done */ + process_completed_job(job, send_page); + QSIMPLEQ_REMOVE_HEAD(&polling_queue, entry); + } else if (status =3D=3D QPL_STS_BEING_PROCESSED) { /* job is runn= ing */ + break; + } else { + abort(); + } + } +} + +static int submit_new_job(IaaJob *job) +{ + qpl_status status; + qpl_job *qpl =3D job->qpl; + + qpl->op =3D job->is_compression ? qpl_op_compress : qpl_op_decompress; + qpl->next_in_ptr =3D job->in_buf; + qpl->next_out_ptr =3D job->out_buf; + qpl->available_in =3D job->in_len; + qpl->available_out =3D qemu_target_page_size(); /* outbuf maximum size= */ + qpl->flags =3D QPL_FLAG_FIRST | QPL_FLAG_LAST | QPL_FLAG_OMIT_VERIFY; + qpl->level =3D 1; /* only level 1 compression is supported */ + + do { + status =3D qpl_submit_job(qpl); + } while (status =3D=3D QPL_STS_QUEUES_ARE_BUSY_ERR); + + if (status !=3D QPL_STS_OK) { + error_report("Failed to submit iaa job, error %d", status); + return -1; + } + QSIMPLEQ_INSERT_TAIL(&polling_queue, job, entry); + return 0; +} + +int flush_iaa_jobs(bool flush_all_jobs, send_iaa_data send_page) +{ + IaaJob *job, *job_next; + + QSIMPLEQ_FOREACH_SAFE(job, &polling_queue, entry, job_next) { + if (check_job_status(job, true) !=3D QPL_STS_OK) { + return -1; + } + process_completed_job(job, send_page); + QSIMPLEQ_REMOVE_HEAD(&polling_queue, entry); + if (!flush_all_jobs) { + break; + } + } + return 0; +} + +int compress_page_with_iaa(RAMBlock *block, ram_addr_t offset, + send_iaa_data send_page) +{ + IaaJob *job; + + if (iaa_job_pool.cnt !=3D 0) { + check_polling_jobs(send_page); + } + if (buffer_is_zero(block->host + offset, qemu_target_page_size())) { + send_page(block, offset, NULL, 0, RES_ZEROPAGE); + return 1; + } + job =3D get_job(send_page); + job->is_compression =3D true; + job->in_buf =3D block->host + offset; + job->in_len =3D qemu_target_page_size(); + job->param.comp.offset =3D offset; + job->param.comp.block =3D block; + return (submit_new_job(job) =3D=3D 0 ? 1 : 0); +} + +int decompress_data_with_iaa(QEMUFile *f, void *host, int len) +{ + IaaJob *job; + + if (iaa_job_pool.cnt !=3D 0) { + check_polling_jobs(NULL); + } + job =3D get_job(NULL); + job->is_compression =3D false; + qemu_get_buffer(f, job->in_buf, len); + job->in_len =3D len; + job->param.decomp.host =3D host; + return submit_new_job(job); +} diff --git a/migration/iaa-ram-compress.h b/migration/iaa-ram-compress.h index 27998b255b..5a555b3b8d 100644 --- a/migration/iaa-ram-compress.h +++ b/migration/iaa-ram-compress.h @@ -15,6 +15,13 @@ #include "qemu-file.h" #include "ram-compress.h" =20 +typedef int (*send_iaa_data) (RAMBlock *block, ram_addr_t offset, uint8_t = *data, + uint32_t data_len, CompressResult result); + int iaa_compress_init(bool is_decompression); void iaa_compress_deinit(void); +int compress_page_with_iaa(RAMBlock *block, ram_addr_t offset, + send_iaa_data send_page); +int decompress_data_with_iaa(QEMUFile *f, void *host, int len); +int flush_iaa_jobs(bool flush_all_jobs, send_iaa_data send_page); #endif diff --git a/migration/ram-compress.c b/migration/ram-compress.c index acc511ce57..0bddf8b9ea 100644 --- a/migration/ram-compress.c +++ b/migration/ram-compress.c @@ -370,10 +370,11 @@ int wait_for_decompress_done(void) return 0; } =20 +#ifdef CONFIG_QPL if (migrate_compress_with_iaa()) { - /* Implement in next patch */ - return 0; + return flush_iaa_jobs(true, NULL); } +#endif =20 thread_count =3D migrate_decompress_threads(); qemu_mutex_lock(&decomp_done_lock); @@ -511,9 +512,12 @@ void ram_compress_save_cleanup(void) =20 void ram_decompress_data(QEMUFile *f, void *host, int len) { +#ifdef CONFIG_QPL if (migrate_compress_with_iaa()) { - /* Implement in next patch */ + decompress_data_with_iaa(f, host, len); + return; } +#endif decompress_data_with_multi_threads(f, host, len); } =20 diff --git a/migration/ram.c b/migration/ram.c index 34ee1de332..5ef818112c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -69,6 +69,9 @@ #include "qemu/userfaultfd.h" #endif /* defined(__linux__) */ =20 +#ifdef CONFIG_QPL +#include "iaa-ram-compress.h" +#endif /***********************************************************/ /* ram save/restore */ =20 @@ -1342,16 +1345,59 @@ static int send_queued_data(CompressParam *param) return len; } =20 +#ifdef CONFIG_QPL +static int send_iaa_compressed_page(RAMBlock *block, ram_addr_t offset, + uint8_t *data, uint32_t data_len, + CompressResult result) +{ + PageSearchStatus *pss =3D &ram_state->pss[RAM_CHANNEL_PRECOPY]; + MigrationState *ms =3D migrate_get_current(); + QEMUFile *file =3D ms->to_dst_file; + int len =3D 0; + + assert(block =3D=3D pss->last_sent_block); + if (result =3D=3D RES_ZEROPAGE) { + len +=3D save_page_header(pss, file, block, offset | RAM_SAVE_FLAG= _ZERO); + qemu_put_byte(file, 0); + len +=3D 1; + ram_release_page(block->idstr, offset); + stat64_add(&mig_stats.zero_pages, 1); + } else if (result =3D=3D RES_COMPRESS) { + assert(data !=3D NULL); + assert((data_len > 0) && (data_len < qemu_target_page_size())); + len +=3D save_page_header(pss, file, block, + offset | RAM_SAVE_FLAG_COMPRESS_PAGE); + qemu_put_be32(file, data_len); + qemu_put_buffer(file, data, data_len); + len +=3D data_len; + /* 8 means a header with RAM_SAVE_FLAG_CONTINUE. */ + compression_counters.compressed_size +=3D len - 8; + compression_counters.pages++; + } else if (result =3D=3D RES_NONE) { + assert((data !=3D NULL) && (data_len =3D=3D TARGET_PAGE_SIZE)); + len +=3D save_page_header(pss, file, block, offset | RAM_SAVE_FLAG= _PAGE); + qemu_put_buffer(file, data, data_len); + len +=3D data_len; + stat64_add(&mig_stats.normal_pages, 1); + } else { + abort(); + } + ram_transferred_add(len); + return len; +} +#endif + static void ram_flush_compressed_data(RAMState *rs) { if (!save_page_use_compression(rs)) { return; } +#ifdef CONFIG_QPL if (migrate_compress_with_iaa()) { - /* Implement in next patch */ + flush_iaa_jobs(true, send_iaa_compressed_page); return; } - +#endif flush_compressed_data(send_queued_data); } =20 @@ -2102,11 +2148,11 @@ static bool save_compress_page(RAMState *rs, PageSe= archStatus *pss, ram_flush_compressed_data(rs); return false; } - +#ifdef CONFIG_QPL if (migrate_compress_with_iaa()) { - /* Implement in next patch */ - return true; + return compress_page_with_iaa(block, offset, send_iaa_compressed_p= age); } +#endif if (compress_page_with_multi_thread(block, offset, send_queued_data) >= 0) { return true; } --=20 2.39.3