From patchwork Sun Dec 31 20:58:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Zhang X-Patchwork-Id: 1881427 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=X7TAju1J; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T3Bsx0hcZz1yfx for ; Mon, 1 Jan 2024 08:22:59 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rK3GA-0001I9-0t; Sun, 31 Dec 2023 16:22:14 -0500 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 1rK2up-000780-IY for qemu-devel@nongnu.org; Sun, 31 Dec 2023 16:00:11 -0500 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rK2un-0007N1-NZ for qemu-devel@nongnu.org; Sun, 31 Dec 2023 16:00:11 -0500 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-78104f6f692so636636585a.1 for ; Sun, 31 Dec 2023 13:00:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1704056406; x=1704661206; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dteAf542Gh+t9jeb7xSrraAPUQpSdtvicUVPJE3U4ww=; b=X7TAju1Jq7lOI7+wZ4GiF+xTN9ogYBR9J/IKR8a8rCWC4vqZ0KU2mqnwKnibYWgxxr C3mm6fgFJoyMWb+rWAmBq7GZq+hZANYOT8Y1NJjEQc50vWAYiTr1sTMZhrlyEzi8Rv7/ nT8fsdgTk8fzwXc+H80JOBt4fqTZ6lpjTTH218DUbHDaOD/CmSt4uKyG+ylVTcI/jYwn GkbRHViLhhV5wfKJzBe2PMUjjM5K9jZIPMf0YVp4RmXOSD+C83sYDvQTImf6AjaAbYzc ki/MFDpn6y9DqdkihV4ZcOQJ8SLzsF18Y8nwD+7ZHu8FthLD+AE47pt8Aq5uhMCFdkHf yJFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704056406; x=1704661206; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dteAf542Gh+t9jeb7xSrraAPUQpSdtvicUVPJE3U4ww=; b=uoDA9Jiu0P30d1QxIEMBz1JmvJ36CRYV7TqlJOEH7im6XHMOCcFSnxCXOXIWt6Ehad vO1BUPibPDndgDMgE6ZpUPci+SFXMfO4NqNcwx8Wa1vTpa+JQoBWhKsJTeZiUL2iVtMf 4//qcrx/YlpuvXctkiFcFBDKKxxPnEdTE0oUdocQRJeEtuwPz0XQKKckA04z+rAWnJhp UpxM6FvNRePlyTTm9RFr6mVcZ/569/DGR3EIVCSUNB87oDS0Ar1ySNtL9xjIWnsAB1FI GtWSYNeU3Ghk5KpVJ3CGWECZIixtXpNlay+jbxWGRBkxVuos4hhBj3qeXmynXNIfRSzO hXvA== X-Gm-Message-State: AOJu0YzIm82Rr4UvKRBI3Z9bIoTsOQJ9y2XKy7c7GG/HliHzKEKcbt2O aSiDyx/hMQp9vDDm5CC0426OLSCJZRb2N9YtcU+Tk8sBAA7Pdw== X-Google-Smtp-Source: AGHT+IHGWslJh0k8SCf0zwZ/4C7W0BYGJh3Xt5tRVqd1rW8AsbaAwS6gNh5sqawHw1WzUOyFC4GwGA== X-Received: by 2002:a05:620a:4309:b0:781:bd80:af82 with SMTP id u9-20020a05620a430900b00781bd80af82mr1545815qko.37.1704056405262; Sun, 31 Dec 2023 13:00:05 -0800 (PST) Received: from n36-186-108.byted.org. ([147.160.184.90]) by smtp.gmail.com with ESMTPSA id pb21-20020a05620a839500b007811da87cefsm8111750qkn.127.2023.12.31.13.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 13:00:05 -0800 (PST) From: Bryan Zhang To: qemu-devel@nongnu.org, farosas@suse.de, marcandre.lureau@redhat.com, peterx@redhat.com, quintela@redhat.com, peter.maydell@linaro.org, hao.xiang@bytedance.com Cc: bryan.zhang@bytedance.com Subject: [PATCH 1/5] meson: Introduce 'qatzip' feature to the build system. Date: Sun, 31 Dec 2023 20:58:00 +0000 Message-Id: <20231231205804.2366509-2-bryan.zhang@bytedance.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231231205804.2366509-1-bryan.zhang@bytedance.com> References: <20231231205804.2366509-1-bryan.zhang@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72d; envelope-from=bryan.zhang@bytedance.com; helo=mail-qk1-x72d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 31 Dec 2023 16:22:08 -0500 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add a 'qatzip' feature, which is automatically disabled, and which depends on the QATzip library if enabled. Signed-off-by: Bryan Zhang Signed-off-by: Hao Xiang --- meson.build | 10 ++++++++++ meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 3 +++ 3 files changed, 15 insertions(+) diff --git a/meson.build b/meson.build index 6c77d9687d..99050b1109 100644 --- a/meson.build +++ b/meson.build @@ -1041,6 +1041,14 @@ if not get_option('zstd').auto() or have_block required: get_option('zstd'), method: 'pkg-config') endif + +qatzip = not_found +if get_option('qatzip').enabled() + qatzip = dependency('qatzip', version: '>=1.1.2', + required: get_option('qatzip'), + method: 'pkg-config') +endif + virgl = not_found have_vhost_user_gpu = have_tools and targetos == 'linux' and pixman.found() @@ -2208,6 +2216,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_QATZIP', qatzip.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()) @@ -4379,6 +4388,7 @@ summary_info += {'snappy support': snappy} summary_info += {'bzip2 support': libbzip2} summary_info += {'lzfse support': liblzfse} summary_info += {'zstd support': zstd} +summary_info += {'QATzip support': qatzip} summary_info += {'NUMA host support': numa} summary_info += {'capstone': capstone} summary_info += {'libpmem support': libpmem} diff --git a/meson_options.txt b/meson_options.txt index c9baeda639..0f3b380f82 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -259,6 +259,8 @@ option('xkbcommon', type : 'feature', value : 'auto', description: 'xkbcommon support') option('zstd', type : 'feature', value : 'auto', description: 'zstd compression support') +option('qatzip', type: 'feature', value: 'disabled', + description: 'QATzip compression 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 680fa3f581..1afd373606 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -164,6 +164,7 @@ meson_options_help() { printf "%s\n" ' plugins TCG plugins via shared library loading' printf "%s\n" ' png PNG support with libpng' printf "%s\n" ' pvrdma Enable PVRDMA support' + printf "%s\n" ' qatzip QATzip compression support' printf "%s\n" ' qcow1 qcow1 image format support' printf "%s\n" ' qed qed image format support' printf "%s\n" ' qga-vss build QGA VSS support (broken with MinGW)' @@ -430,6 +431,8 @@ _meson_option_parse() { --prefix=*) quote_sh "-Dprefix=$2" ;; --enable-pvrdma) printf "%s" -Dpvrdma=enabled ;; --disable-pvrdma) printf "%s" -Dpvrdma=disabled ;; + --enable-qatzip) printf "%s" -Dqatzip=enabled ;; + --disable-qatzip) printf "%s" -Dqatzip=disabled ;; --enable-qcow1) printf "%s" -Dqcow1=enabled ;; --disable-qcow1) printf "%s" -Dqcow1=disabled ;; --enable-qed) printf "%s" -Dqed=enabled ;; From patchwork Sun Dec 31 20:58:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Zhang X-Patchwork-Id: 1881429 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=kpgeYdSJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T3Bt13m0xz23f7 for ; Mon, 1 Jan 2024 08:23:05 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rK3G7-0001Hi-Kt; Sun, 31 Dec 2023 16:22:12 -0500 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 1rK2uq-00078F-Ei for qemu-devel@nongnu.org; Sun, 31 Dec 2023 16:00:12 -0500 Received: from mail-qv1-xf33.google.com ([2607:f8b0:4864:20::f33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rK2uo-0007O9-25 for qemu-devel@nongnu.org; Sun, 31 Dec 2023 16:00:11 -0500 Received: by mail-qv1-xf33.google.com with SMTP id 6a1803df08f44-6808c3938afso19386596d6.1 for ; Sun, 31 Dec 2023 13:00:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1704056408; x=1704661208; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KFMYKbvGtBzN+tfuFjKDhZboY6Ude5pmCu0Q8MJ27FM=; b=kpgeYdSJoQiSEFFmMQZhgcuhEPCTji35t1g2FM2N2Ny0daFJTnaEs1KKLiCxplmql4 17y8YFBBd0DRvGBD1v3OMoq2zDPU8soHAhMeNWM1YtQQDfX7tHA4RvnATfyWDIc5xb7e XODOY1SvEZQNr6PA+jAM2MM2uu5bSr18q55uma6SySaULcp2pg5uuwpkjRJQZEvMJcNL 4L214ZR6ui3vMF0dHjF54W9GzBK9URlBR2PqIv6m5jUVPbAVGC7f/j6y6ksUlMrK8hgx uO0MBBgy5Zd1FXD+zoWeogbVUFgg5qTUGVi6ng2WaJdQI1AH5bqZsj5ghE1GRH0DuEmf QsxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704056408; x=1704661208; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KFMYKbvGtBzN+tfuFjKDhZboY6Ude5pmCu0Q8MJ27FM=; b=SrI7EgcUZgNlawhQTcV9OsEPw9Po10RD1L05KM/EeNmBhWouZlvW3zBdbu/0V7ZLCu 8b18rjEsbCp7fCgAOYf1tnoMWhMA6PrkkrLlp5TMCvC3wGWE88HQ7d30QmbAO97D/4nJ K9B2F3TxdL0ySfYRYDkeO1NxEu6ih9a3S6T7H1z5GiNAhcof0Hf3yXrBbMAapXILV4cL afgu0CltM3OEe7mhQ8+paJfCNYkDZquKnBpYu7CCRlD9V/f9T/yOUh5JMrlr0WI0x/Rp v1TU+pDOD5S/y64yktmGRcWde2rBs+ATz03dxfk4NGADJHCDTHvbq9+qCyRUUxnJYNDZ +ACQ== X-Gm-Message-State: AOJu0YyLRG4nImli57URP69XwSbtiIBsqOBw+9LnAinNdMXGtDeOk4Ul PgfXjNrnyKnl8cOqRUPvfPqRfnR5LgYQA48wNX7rmi1u8qk= X-Google-Smtp-Source: AGHT+IHrg71Oi9EpoDk30amwO3unQ9XbCFWFyVd5iTewWYerQNTfM3pEStF0dnkzYWWBMZcAroYvhg== X-Received: by 2002:a05:620a:1138:b0:781:33e3:ec1b with SMTP id p24-20020a05620a113800b0078133e3ec1bmr18330845qkk.18.1704056408286; Sun, 31 Dec 2023 13:00:08 -0800 (PST) Received: from n36-186-108.byted.org. ([147.160.184.90]) by smtp.gmail.com with ESMTPSA id pb21-20020a05620a839500b007811da87cefsm8111750qkn.127.2023.12.31.13.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 13:00:07 -0800 (PST) From: Bryan Zhang To: qemu-devel@nongnu.org, farosas@suse.de, marcandre.lureau@redhat.com, peterx@redhat.com, quintela@redhat.com, peter.maydell@linaro.org, hao.xiang@bytedance.com Cc: bryan.zhang@bytedance.com Subject: [PATCH 2/5] migration: Add compression level parameter for QATzip Date: Sun, 31 Dec 2023 20:58:01 +0000 Message-Id: <20231231205804.2366509-3-bryan.zhang@bytedance.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231231205804.2366509-1-bryan.zhang@bytedance.com> References: <20231231205804.2366509-1-bryan.zhang@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::f33; envelope-from=bryan.zhang@bytedance.com; helo=mail-qv1-xf33.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 31 Dec 2023 16:22:09 -0500 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Adds support for a parameter to specify QATzip compression level. This is a preparatory commit for a subsequent commit that will actually use QATzip compression. Signed-off-by: Bryan Zhang Signed-off-by: Hao Xiang --- migration/migration-hmp-cmds.c | 4 ++++ migration/options.c | 27 +++++++++++++++++++++++++++ migration/options.h | 1 + qapi/migration.json | 19 ++++++++++++++++++- 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 99710c8ffb..c3a8f1888d 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -628,6 +628,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict) p->has_multifd_zlib_level = true; visit_type_uint8(v, param, &p->multifd_zlib_level, &err); break; + case MIGRATION_PARAMETER_MULTIFD_QATZIP_LEVEL: + p->has_multifd_qatzip_level = true; + visit_type_uint8(v, param, &p->multifd_qatzip_level, &err); + break; case MIGRATION_PARAMETER_MULTIFD_ZSTD_LEVEL: p->has_multifd_zstd_level = true; visit_type_uint8(v, param, &p->multifd_zstd_level, &err); diff --git a/migration/options.c b/migration/options.c index 8d8ec73ad9..4a931effae 100644 --- a/migration/options.c +++ b/migration/options.c @@ -62,6 +62,12 @@ #define DEFAULT_MIGRATE_MULTIFD_COMPRESSION MULTIFD_COMPRESSION_NONE /* 0: means nocompress, 1: best speed, ... 9: best compress ratio */ #define DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL 1 +/* + * 1: best speed, ... 9: best compress ratio + * There is some nuance here. Refer to QATzip documentation to understand + * the mapping of QATzip levels to standard deflate levels. + */ +#define DEFAULT_MIGRATE_MULTIFD_QATZIP_LEVEL 1 /* 0: means nocompress, 1: best speed, ... 20: best compress ratio */ #define DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL 1 @@ -143,6 +149,9 @@ Property migration_properties[] = { DEFINE_PROP_UINT8("multifd-zlib-level", MigrationState, parameters.multifd_zlib_level, DEFAULT_MIGRATE_MULTIFD_ZLIB_LEVEL), + DEFINE_PROP_UINT8("multifd-qatzip-level", MigrationState, + parameters.multifd_qatzip_level, + DEFAULT_MIGRATE_MULTIFD_QATZIP_LEVEL), DEFINE_PROP_UINT8("multifd-zstd-level", MigrationState, parameters.multifd_zstd_level, DEFAULT_MIGRATE_MULTIFD_ZSTD_LEVEL), @@ -859,6 +868,13 @@ int migrate_multifd_zlib_level(void) return s->parameters.multifd_zlib_level; } +int migrate_multifd_qatzip_level(void) +{ + MigrationState *s = migrate_get_current(); + + return s->parameters.multifd_qatzip_level; +} + int migrate_multifd_zstd_level(void) { MigrationState *s = migrate_get_current(); @@ -981,6 +997,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp) params->multifd_compression = s->parameters.multifd_compression; params->has_multifd_zlib_level = true; params->multifd_zlib_level = s->parameters.multifd_zlib_level; + params->has_multifd_qatzip_level = true; + params->multifd_qatzip_level = s->parameters.multifd_qatzip_level; params->has_multifd_zstd_level = true; params->multifd_zstd_level = s->parameters.multifd_zstd_level; params->has_xbzrle_cache_size = true; @@ -1036,6 +1054,7 @@ void migrate_params_init(MigrationParameters *params) params->has_multifd_channels = true; params->has_multifd_compression = true; params->has_multifd_zlib_level = true; + params->has_multifd_qatzip_level = true; params->has_multifd_zstd_level = true; params->has_xbzrle_cache_size = true; params->has_max_postcopy_bandwidth = true; @@ -1145,6 +1164,14 @@ bool migrate_params_check(MigrationParameters *params, Error **errp) return false; } + if (params->has_multifd_qatzip_level && + ((params->multifd_qatzip_level > 9) || + (params->multifd_qatzip_level < 1))) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "multifd_qatzip_level", + "a value between 1 and 9"); + return false; + } + if (params->has_multifd_zstd_level && (params->multifd_zstd_level > 20)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "multifd_zstd_level", diff --git a/migration/options.h b/migration/options.h index 246c160aee..82707f34d0 100644 --- a/migration/options.h +++ b/migration/options.h @@ -87,6 +87,7 @@ MigMode migrate_mode(void); int migrate_multifd_channels(void); MultiFDCompression migrate_multifd_compression(void); int migrate_multifd_zlib_level(void); +int migrate_multifd_qatzip_level(void); int migrate_multifd_zstd_level(void); uint8_t migrate_throttle_trigger_threshold(void); const char *migrate_tls_authz(void); diff --git a/qapi/migration.json b/qapi/migration.json index eb2f883513..6d5a4b0489 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -842,6 +842,11 @@ # speed, and 9 means best compression ratio which will consume # more CPU. Defaults to 1. (Since 5.0) # +# @multifd-qatzip-level: Set the compression level to be used in live +# migration. The level is an integer between 1 and 9, where 1 means +# the best compression speed, and 9 means the best compression +# ratio which will consume more CPU. Defaults to 1. +# # @multifd-zstd-level: Set the compression level to be used in live # migration, the compression level is an integer between 0 and 20, # where 0 means no compression, 1 means the best compression @@ -903,7 +908,7 @@ 'multifd-channels', 'xbzrle-cache-size', 'max-postcopy-bandwidth', 'max-cpu-throttle', 'multifd-compression', - 'multifd-zlib-level', 'multifd-zstd-level', + 'multifd-zlib-level', 'multifd-qatzip-level', 'multifd-zstd-level', 'block-bitmap-mapping', { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable'] }, 'vcpu-dirty-limit', @@ -1030,6 +1035,11 @@ # speed, and 9 means best compression ratio which will consume # more CPU. Defaults to 1. (Since 5.0) # +# @multifd-qatzip-level: Set the compression level to be used in live +# migration. The level is an integer between 1 and 9, where 1 means +# the best compression speed, and 9 means the best compression +# ratio which will consume more CPU. Defaults to 1. +# # @multifd-zstd-level: Set the compression level to be used in live # migration, the compression level is an integer between 0 and 20, # where 0 means no compression, 1 means the best compression @@ -1110,6 +1120,7 @@ '*max-cpu-throttle': 'uint8', '*multifd-compression': 'MultiFDCompression', '*multifd-zlib-level': 'uint8', + '*multifd-qatzip-level': 'uint8', '*multifd-zstd-level': 'uint8', '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ], '*x-vcpu-dirty-limit-period': { 'type': 'uint64', @@ -1258,6 +1269,11 @@ # speed, and 9 means best compression ratio which will consume # more CPU. Defaults to 1. (Since 5.0) # +# @multifd-qatzip-level: Set the compression level to be used in live +# migration. The level is an integer between 1 and 9, where 1 means +# the best compression speed, and 9 means the best compression +# ratio which will consume more CPU. Defaults to 1. +# # @multifd-zstd-level: Set the compression level to be used in live # migration, the compression level is an integer between 0 and 20, # where 0 means no compression, 1 means the best compression @@ -1335,6 +1351,7 @@ '*max-cpu-throttle': 'uint8', '*multifd-compression': 'MultiFDCompression', '*multifd-zlib-level': 'uint8', + '*multifd-qatzip-level': 'uint8', '*multifd-zstd-level': 'uint8', '*block-bitmap-mapping': [ 'BitmapMigrationNodeAlias' ], '*x-vcpu-dirty-limit-period': { 'type': 'uint64', From patchwork Sun Dec 31 20:58:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Zhang X-Patchwork-Id: 1881432 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=R5hqspML; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T3BtY2Kmhz1yfx for ; Mon, 1 Jan 2024 08:23:33 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rK3GD-0001Iw-F8; Sun, 31 Dec 2023 16:22:17 -0500 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 1rK2ut-00078Y-Kp for qemu-devel@nongnu.org; Sun, 31 Dec 2023 16:00:17 -0500 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rK2ur-0007OS-93 for qemu-devel@nongnu.org; Sun, 31 Dec 2023 16:00:14 -0500 Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-781753f52afso273902685a.2 for ; Sun, 31 Dec 2023 13:00:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1704056410; x=1704661210; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tgDAcZPCAo2TEHKw7RAzVC63QmD5BA9tquuYbmv13q8=; b=R5hqspMLVnxKAy75AGhAxozatZ3OTZLStrsg9K8g/ICVgMczn6m22+rsPC6TdF09RO 4eZg4LpyOxSNyRaNCLvIOfqlsGofuBNWRJ+wDBRhOUUgfQPMwyzyPLVPK/bUH6HI/Rzc bmuzgUhhYF1Og0/TGK3yqKcx2/y/MsNsS9ctCMmxu+Zxz3Do3BJ2IL6MCGkMuMh3mkv9 R244dBZzrzxK9WPMZkx2qK5Pm/R0jlX92zo4+H+18pCGOHTxoSYhTVDPxRMTxVZaY29a Tc+9Rgm8zaD3OjoLcFjYhHAvmllJJ4GSTF+GSG1A0weqIir6cmzdzDI+2CTuVjoKBLqc BDPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704056410; x=1704661210; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tgDAcZPCAo2TEHKw7RAzVC63QmD5BA9tquuYbmv13q8=; b=CPuraxV85VBqeqvGYHlwvRu9hGG1OTUd7rUpv50aijjJCwWq34LwT2/tZLrQ6yFMIR Obr/vaSeswRVlmJSPauAaLNhkVYpKexwjZFVevn+BAbMAdE85TolM/nrS8FGlaUwClxZ LZVazT+46Ejl7CKYx6h3iGPfbp8c8jvcz4EQuyA9irf4BedaRpCeLqHXMVdAV4sAjjIE 5TBs1aJLeGVTgIMZPQvqajQCLa8QKhCsVFfMCLb+REvTuGuvr5H7/yftmtbir4i7JEu9 +jGfVEf4JGIA4EG5bVpMpskQEFu8C+LHXR8/6P5/QWrZtfafKg6MLd+pNzG1+C8jtzyj NV/A== X-Gm-Message-State: AOJu0YwUMFh8+myMHjhP/qlCsLuFHwbYrCJaHolGMd0KAFG85tLZxo2A SsNC68sIOlw54NEucgikESACY5+iFixG6h1tezPMhyDvw/Y= X-Google-Smtp-Source: AGHT+IFRVQdZuGK55MEDEqf4lIq/P/CKi91beolpQ8cnDNp64jaxP5FCfZ/km67ldmanxAQeoQ9+HQ== X-Received: by 2002:a05:620a:5596:b0:77d:98aa:f7d3 with SMTP id vq22-20020a05620a559600b0077d98aaf7d3mr18338804qkn.13.1704056410335; Sun, 31 Dec 2023 13:00:10 -0800 (PST) Received: from n36-186-108.byted.org. ([147.160.184.90]) by smtp.gmail.com with ESMTPSA id pb21-20020a05620a839500b007811da87cefsm8111750qkn.127.2023.12.31.13.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 13:00:10 -0800 (PST) From: Bryan Zhang To: qemu-devel@nongnu.org, farosas@suse.de, marcandre.lureau@redhat.com, peterx@redhat.com, quintela@redhat.com, peter.maydell@linaro.org, hao.xiang@bytedance.com Cc: bryan.zhang@bytedance.com Subject: [PATCH 3/5] migration: Introduce unimplemented 'qatzip' compression method Date: Sun, 31 Dec 2023 20:58:02 +0000 Message-Id: <20231231205804.2366509-4-bryan.zhang@bytedance.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231231205804.2366509-1-bryan.zhang@bytedance.com> References: <20231231205804.2366509-1-bryan.zhang@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=bryan.zhang@bytedance.com; helo=mail-qk1-x730.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 31 Dec 2023 16:22:09 -0500 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Adds support for 'qatzip' as an option for the multifd compression method parameter, but copy-pastes the no-op logic to leave the actual methods effectively unimplemented. This is in preparation of a subsequent commit that will implement actually using QAT for compression and decompression. Signed-off-by: Bryan Zhang Signed-off-by: Hao Xiang --- hw/core/qdev-properties-system.c | 6 ++- migration/meson.build | 1 + migration/multifd-qatzip.c | 81 ++++++++++++++++++++++++++++++++ migration/multifd.h | 1 + qapi/migration.json | 5 +- 5 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 migration/multifd-qatzip.c diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 1a396521d5..d8e48dcb0e 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -658,7 +658,11 @@ const PropertyInfo qdev_prop_fdc_drive_type = { const PropertyInfo qdev_prop_multifd_compression = { .name = "MultiFDCompression", .description = "multifd_compression values, " - "none/zlib/zstd", + "none/zlib/zstd" +#ifdef CONFIG_QATZIP + "/qatzip" +#endif + , .enum_table = &MultiFDCompression_lookup, .get = qdev_propinfo_get_enum, .set = qdev_propinfo_set_enum, diff --git a/migration/meson.build b/migration/meson.build index 92b1cc4297..e20f318379 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: qatzip, if_true: files('multifd-qatzip.c')) specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: files('ram.c', diff --git a/migration/multifd-qatzip.c b/migration/multifd-qatzip.c new file mode 100644 index 0000000000..1733bbddb7 --- /dev/null +++ b/migration/multifd-qatzip.c @@ -0,0 +1,81 @@ +/* + * Multifd QATzip compression implementation + * + * Copyright (c) Bytedance + * + * Authors: + * Bryan Zhang + * Hao Xiang + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "exec/ramblock.h" +#include "exec/target_page.h" +#include "qapi/error.h" +#include "migration.h" +#include "options.h" +#include "multifd.h" + +static int qatzip_send_setup(MultiFDSendParams *p, Error **errp) +{ + return 0; +} + +static void qatzip_send_cleanup(MultiFDSendParams *p, Error **errp) {}; + +static int qatzip_send_prepare(MultiFDSendParams *p, Error **errp) +{ + MultiFDPages_t *pages = p->pages; + + for (int i = 0; i < p->normal_num; i++) { + p->iov[p->iovs_num].iov_base = pages->block->host + p->normal[i]; + p->iov[p->iovs_num].iov_len = p->page_size; + p->iovs_num++; + } + + p->next_packet_size = p->normal_num * p->page_size; + p->flags |= MULTIFD_FLAG_NOCOMP; + return 0; +} + +static int qatzip_recv_setup(MultiFDRecvParams *p, Error **errp) +{ + return 0; +} + +static void qatzip_recv_cleanup(MultiFDRecvParams *p) {}; + +static int qatzip_recv_pages(MultiFDRecvParams *p, Error **errp) +{ + uint32_t flags = p->flags & MULTIFD_FLAG_COMPRESSION_MASK; + + if (flags != MULTIFD_FLAG_NOCOMP) { + error_setg(errp, "multifd %u: flags received %x flags expected %x", + p->id, flags, MULTIFD_FLAG_NOCOMP); + return -1; + } + for (int i = 0; i < p->normal_num; i++) { + p->iov[i].iov_base = p->host + p->normal[i]; + p->iov[i].iov_len = p->page_size; + } + return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp); +} + +static MultiFDMethods multifd_qatzip_ops = { + .send_setup = qatzip_send_setup, + .send_cleanup = qatzip_send_cleanup, + .send_prepare = qatzip_send_prepare, + .recv_setup = qatzip_recv_setup, + .recv_cleanup = qatzip_recv_cleanup, + .recv_pages = qatzip_recv_pages +}; + +static void multifd_qatzip_register(void) +{ + multifd_register_ops(MULTIFD_COMPRESSION_QATZIP, &multifd_qatzip_ops); +} + +migration_init(multifd_qatzip_register); diff --git a/migration/multifd.h b/migration/multifd.h index a835643b48..5600f7fc82 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -33,6 +33,7 @@ int multifd_queue_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset); #define MULTIFD_FLAG_NOCOMP (0 << 1) #define MULTIFD_FLAG_ZLIB (1 << 1) #define MULTIFD_FLAG_ZSTD (2 << 1) +#define MULTIFD_FLAG_QATZIP (3 << 1) /* This value needs to be a multiple of qemu_target_page_size() */ #define MULTIFD_PACKET_SIZE (512 * 1024) diff --git a/qapi/migration.json b/qapi/migration.json index 6d5a4b0489..e3cc195aed 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -625,11 +625,14 @@ # # @zstd: use zstd compression method. # +# @qatzip: use qatzip compression method. +# # Since: 5.0 ## { 'enum': 'MultiFDCompression', 'data': [ 'none', 'zlib', - { 'name': 'zstd', 'if': 'CONFIG_ZSTD' } ] } + { 'name': 'zstd', 'if': 'CONFIG_ZSTD' }, + { 'name': 'qatzip', 'if': 'CONFIG_QATZIP'} ] } ## # @MigMode: From patchwork Sun Dec 31 20:58:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Zhang X-Patchwork-Id: 1881430 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=SGu24BRZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T3BtB0THyz1yfx for ; Mon, 1 Jan 2024 08:23:14 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rK3GD-0001Ih-8r; Sun, 31 Dec 2023 16:22:17 -0500 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 1rK2ux-00078n-1H for qemu-devel@nongnu.org; Sun, 31 Dec 2023 16:00:20 -0500 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rK2uu-0007QM-SO for qemu-devel@nongnu.org; Sun, 31 Dec 2023 16:00:18 -0500 Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-781b9922f44so67229085a.2 for ; Sun, 31 Dec 2023 13:00:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1704056415; x=1704661215; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lfKrdv08TX0rJ6x8vnK6oFLE9GkUtVpHlgcxnHxsOPE=; b=SGu24BRZLNAI4c7zUB1c6vjVpk1aAJtHdh6637v/8NJH5BWnjufXRydaf1r6sJJZ/j E4zn/KCB1kmXWT3IkIILzRReKRcQ7/tqAFoCa7ykzpBT5TNV8cHM/BmZUX6oDFFSAj8Y Ag+nXK7412nfXpEwrd5QhARL3UNqrdjuGH7eN9InnSVhesu/JCYl3x9tDB9qxF6e4zbo O0nlWKtbpCmZiKv+addga/g4wW/gugVJnsT/SyYPgvGmlAIRFhh9SPCFcdLcMNGsPX8X txhOdf73xjH02tCgVlVXc/jkHjs7bUUyd2h9HHDrandD0l3X7tgiLJ8aO2Czebl0g7MO 0CrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704056415; x=1704661215; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lfKrdv08TX0rJ6x8vnK6oFLE9GkUtVpHlgcxnHxsOPE=; b=CzsjenjrINnD5bBoWzUoCfQv+nYNy5AoldB8wz25TYiHW9p+778pMnPer4hN3OQNRa 5JTeJlDh4x6EbMRC1GLi/kS/Kel8+BiD+QWXQjMfK5yVJG0ev4ssHujxH6qs99ID2H21 x8H1j0UJcu7in/Ku6NePGD3JmA7cDq60NokyYMJxuVTGxhum6tjNrEkP+p8j1oHioct2 WkJ/jFzfC21aaKTrx2leWo9946tOiLswMdpm0xvYEMgDYVI519oOsf/CrfDc/giR0akE j/L/m1azAVd/BzVXoLYf7HFljDQzXtgwpaQ9KLbJxYyDGos99nb3hFqwpI0jzdbeR9GK WOnQ== X-Gm-Message-State: AOJu0YxIdk4F8kNaAcYxf7WyG3M8qmGCwnHYZXvMinotdC57+Ih/tTRk PLuUleIew/cXZWf583mQHcNtHjyEQ34Eu52158aZiRwd6PA= X-Google-Smtp-Source: AGHT+IH+sh1HJmKRIlFWbluEJY8n63jrcvOjUO1TOhn9YClUNXLf6Mi4B9Opqd//pPVlbpbGpS6EGQ== X-Received: by 2002:a05:620a:22ef:b0:781:7ac2:630f with SMTP id p15-20020a05620a22ef00b007817ac2630fmr6706290qki.98.1704056415338; Sun, 31 Dec 2023 13:00:15 -0800 (PST) Received: from n36-186-108.byted.org. ([147.160.184.90]) by smtp.gmail.com with ESMTPSA id pb21-20020a05620a839500b007811da87cefsm8111750qkn.127.2023.12.31.13.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 13:00:15 -0800 (PST) From: Bryan Zhang To: qemu-devel@nongnu.org, farosas@suse.de, marcandre.lureau@redhat.com, peterx@redhat.com, quintela@redhat.com, peter.maydell@linaro.org, hao.xiang@bytedance.com Cc: bryan.zhang@bytedance.com Subject: [PATCH 4/5] migration: Implement 'qatzip' methods using QAT Date: Sun, 31 Dec 2023 20:58:03 +0000 Message-Id: <20231231205804.2366509-5-bryan.zhang@bytedance.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231231205804.2366509-1-bryan.zhang@bytedance.com> References: <20231231205804.2366509-1-bryan.zhang@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=bryan.zhang@bytedance.com; helo=mail-qk1-x72e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 31 Dec 2023 16:22:09 -0500 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Uses QAT to offload deflate compression in the 'qatzip' compression method for multifd migration. Signed-off-by: Bryan Zhang Signed-off-by: Hao Xiang --- migration/multifd-qatzip.c | 314 +++++++++++++++++++++++++++++++++++-- 1 file changed, 301 insertions(+), 13 deletions(-) diff --git a/migration/multifd-qatzip.c b/migration/multifd-qatzip.c index 1733bbddb7..3fb0bb5b27 100644 --- a/migration/multifd-qatzip.c +++ b/migration/multifd-qatzip.c @@ -18,50 +18,338 @@ #include "migration.h" #include "options.h" #include "multifd.h" +#include +struct qatzip_data { + /* + * Unique session for use with QATzip API + */ + QzSession_T sess; + + /* + * For compression: Buffer for pages to compress + * For decompression: Buffer for data to decompress + */ + uint8_t *in_buf; + uint32_t in_len; + + /* + * For compression: Output buffer of compressed data + * For decompression: Output buffer of decompressed data + */ + uint8_t *out_buf; + uint32_t out_len; +}; + +/** + * qatzip_send_setup: Set up QATzip session and private buffers. + * + * @param p Multifd channel params + * @param errp Pointer to error, which will be set in case of error + * @return 0 on success, -1 on error (and *errp will be set) + */ static int qatzip_send_setup(MultiFDSendParams *p, Error **errp) { + struct qatzip_data *q; + QzSessionParamsDeflate_T params; + const char *err_msg; + int ret; + + q = g_new0(struct qatzip_data, 1); + p->data = q; + + ret = qzInit(&q->sess, 0); + if (ret != QZ_OK && ret != QZ_DUPLICATE) { + err_msg = "qzInit failed"; + goto err_free_q; + } + + ret = qzGetDefaultsDeflate(¶ms); + if (ret != QZ_OK) { + err_msg = "qzGetDefaultsDeflate failed"; + goto err_close; + } + + /* Use maximum hardware buffer size to improve batching. */ + params.common_params.hw_buff_sz = QZ_HW_BUFF_MAX_SZ; + + /* Make sure to use configured QATzip compression level. */ + params.common_params.comp_lvl = migrate_multifd_qatzip_level(); + + ret = qzSetupSessionDeflate(&q->sess, ¶ms); + if (ret != QZ_OK && ret != QZ_DUPLICATE) { + err_msg = "qzSetupSessionDeflate failed"; + goto err_close; + } + + /* TODO Add support for larger packets. */ + if (MULTIFD_PACKET_SIZE > UINT32_MAX) { + err_msg = "packet size too large for QAT"; + goto err_close; + } + + q->in_len = MULTIFD_PACKET_SIZE; + q->in_buf = g_try_malloc(q->in_len); + if (!q->in_buf) { + err_msg = "malloc failed"; + goto err_close; + } + + q->out_len = qzMaxCompressedLength(MULTIFD_PACKET_SIZE, &q->sess); + q->out_buf = g_try_malloc(q->out_len); + if (!q->out_buf) { + err_msg = "malloc failed"; + goto err_free_inbuf; + } + return 0; + +err_free_inbuf: + g_free(q->in_buf); +err_close: + qzClose(&q->sess); +err_free_q: + g_free(q); + error_setg(errp, "multifd %u: %s", p->id, err_msg); + return -1; } -static void qatzip_send_cleanup(MultiFDSendParams *p, Error **errp) {}; +/** + * qatzip_send_cleanup: Tear down QATzip session and release private buffers. + * + * @param p Multifd channel params + * @param errp Pointer to error, which will be set in case of error + * @return None + */ +static void qatzip_send_cleanup(MultiFDSendParams *p, Error **errp) +{ + struct qatzip_data *q = p->data; + const char *err_msg; + int ret; + + ret = qzTeardownSession(&q->sess); + if (ret != QZ_OK) { + err_msg = "qzTeardownSession failed"; + goto err; + } + + ret = qzClose(&q->sess); + if (ret != QZ_OK) { + err_msg = "qzClose failed"; + goto err; + } + + g_free(q->in_buf); + q->in_buf = NULL; + g_free(q->out_buf); + q->out_buf = NULL; + g_free(p->data); + p->data = NULL; + return; + +err: + error_setg(errp, "multifd %u: %s", p->id, err_msg); +} +/** + * qatzip_send_prepare: Compress pages and update IO channel info. + * + * @param p Multifd channel params + * @param errp Pointer to error, which will be set in case of error + * @return 0 on success, -1 on error (and *errp will be set) + */ static int qatzip_send_prepare(MultiFDSendParams *p, Error **errp) { - MultiFDPages_t *pages = p->pages; + struct qatzip_data *q = p->data; + int ret; + unsigned int in_len, out_len; + /* memcpy all the pages into one buffer. */ for (int i = 0; i < p->normal_num; i++) { - p->iov[p->iovs_num].iov_base = pages->block->host + p->normal[i]; - p->iov[p->iovs_num].iov_len = p->page_size; - p->iovs_num++; + memcpy(q->in_buf + (i * p->page_size), + p->pages->block->host + p->normal[i], + p->page_size); + } + + in_len = p->normal_num * p->page_size; + if (in_len > q->in_len) { + error_setg(errp, "multifd %u: unexpectedly large input", p->id); + return -1; + } + out_len = q->out_len; + + /* + * Unlike other multifd compression implementations, we use a non-streaming + * API and place all the data into one buffer, rather than sending each page + * to the compression API at a time. Based on initial benchmarks, the + * non-streaming API outperforms the streaming API. Plus, the logic in QEMU + * is friendly to using the non-streaming API anyway. If either of these + * statements becomes no longer true, we can revisit adding a streaming + * implementation. + */ + ret = qzCompress(&q->sess, q->in_buf, &in_len, q->out_buf, &out_len, 1); + if (ret != QZ_OK) { + error_setg(errp, "multifd %u: QATzip returned %d instead of QZ_OK", + p->id, ret); + return -1; + } + if (in_len != p->normal_num * p->page_size) { + error_setg(errp, "multifd %u: QATzip failed to compress all input", + p->id); + return -1; } - p->next_packet_size = p->normal_num * p->page_size; - p->flags |= MULTIFD_FLAG_NOCOMP; + p->iov[p->iovs_num].iov_base = q->out_buf; + p->iov[p->iovs_num].iov_len = out_len; + p->iovs_num++; + p->next_packet_size = out_len; + p->flags |= MULTIFD_FLAG_QATZIP; return 0; } +/** + * qatzip_recv_setup: Set up QATzip session and allocate private buffers. + * + * @param p Multifd channel params + * @param errp Pointer to error, which will be set in case of error + * @return 0 on success, -1 on error (and *errp will be set) + */ static int qatzip_recv_setup(MultiFDRecvParams *p, Error **errp) { + struct qatzip_data *q; + QzSessionParamsDeflate_T params; + const char *err_msg; + int ret; + + q = g_new0(struct qatzip_data, 1); + p->data = q; + + ret = qzInit(&q->sess, 0); + if (ret != QZ_OK && ret != QZ_DUPLICATE) { + err_msg = "qzInit failed"; + goto err_free_q; + } + + ret = qzGetDefaultsDeflate(¶ms); + if (ret != QZ_OK) { + err_msg = "qzGetDefaultsDeflate failed"; + goto err_close; + } + + /* Set maximum hardware buffer size for improved batching. */ + params.common_params.hw_buff_sz = QZ_HW_BUFF_MAX_SZ; + + /* Make sure to use configured QATzip compression level. */ + params.common_params.comp_lvl = migrate_multifd_qatzip_level(); + + ret = qzSetupSessionDeflate(&q->sess, ¶ms); + if (ret != QZ_OK && ret != QZ_DUPLICATE) { + err_msg = "qzSetupSessionDeflate failed"; + goto err_close; + } + + /* + * Mimic multifd-zlib, which reserves extra space for the incoming packet. + */ + q->in_len = MULTIFD_PACKET_SIZE * 2; + q->in_buf = g_try_malloc(q->in_len); + if (!q->in_buf) { + err_msg = "malloc failed"; + goto err_close; + } + + q->out_len = MULTIFD_PACKET_SIZE; + q->out_buf = g_try_malloc(q->out_len); + if (!q->out_buf) { + err_msg = "malloc failed"; + goto err_free_inbuf; + } + return 0; + +err_free_inbuf: + g_free(q->in_buf); +err_close: + qzClose(&q->sess); +err_free_q: + g_free(q); + error_setg(errp, "multifd %u: %s", p->id, err_msg); + return -1; } -static void qatzip_recv_cleanup(MultiFDRecvParams *p) {}; +/** + * qatzip_recv_cleanup: Tear down QATzip session and release private buffers. + * + * @param p Multifd channel params + * @return None + */ +static void qatzip_recv_cleanup(MultiFDRecvParams *p) +{ + struct qatzip_data *q = p->data; + + /* Ignoring return values here due to function signature. */ + qzTeardownSession(&q->sess); + qzClose(&q->sess); + g_free(q->in_buf); + g_free(q->out_buf); + g_free(p->data); +} + +/** + * qatzip_recv_pages: Decompress pages and copy them to the appropriate + * locations. + * + * @param p Multifd channel params + * @param errp Pointer to error, which will be set in case of error + * @return 0 on success, -1 on error (and *errp will be set) + */ static int qatzip_recv_pages(MultiFDRecvParams *p, Error **errp) { + struct qatzip_data *q = p->data; + int ret; + unsigned int in_len, out_len; + uint32_t in_size = p->next_packet_size; + uint32_t expected_size = p->normal_num * p->page_size; uint32_t flags = p->flags & MULTIFD_FLAG_COMPRESSION_MASK; - if (flags != MULTIFD_FLAG_NOCOMP) { + if (in_size > q->in_len) { + error_setg(errp, "multifd %u: received unexpectedly large packet", + p->id); + return -1; + } + + if (flags != MULTIFD_FLAG_QATZIP) { error_setg(errp, "multifd %u: flags received %x flags expected %x", - p->id, flags, MULTIFD_FLAG_NOCOMP); + p->id, flags, MULTIFD_FLAG_QATZIP); + return -1; + } + + ret = qio_channel_read_all(p->c, (void *)q->in_buf, in_size, errp); + if (ret != 0) { + return ret; + } + + in_len = in_size; + out_len = q->out_len; + ret = qzDecompress(&q->sess, q->in_buf, &in_len, q->out_buf, &out_len); + if (ret != QZ_OK) { + error_setg(errp, "multifd %u: qzDecompress failed", p->id); + return -1; + } + if (out_len != expected_size) { + error_setg(errp, "multifd %u: packet size received %u size expected %u", + p->id, out_len, expected_size); return -1; } + + /* Copy each page to its appropriate location. */ for (int i = 0; i < p->normal_num; i++) { - p->iov[i].iov_base = p->host + p->normal[i]; - p->iov[i].iov_len = p->page_size; + memcpy(p->host + p->normal[i], + q->out_buf + p->page_size * i, + p->page_size); } - return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp); + return 0; } static MultiFDMethods multifd_qatzip_ops = { From patchwork Sun Dec 31 20:58:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Zhang X-Patchwork-Id: 1881428 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=Psp6gflt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T3Bsx10Sxz23dB for ; Mon, 1 Jan 2024 08:22:59 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rK3GB-0001IA-Ot; Sun, 31 Dec 2023 16:22:15 -0500 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 1rK2ux-00078o-Ql for qemu-devel@nongnu.org; Sun, 31 Dec 2023 16:00:21 -0500 Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rK2uw-0007R2-7x for qemu-devel@nongnu.org; Sun, 31 Dec 2023 16:00:19 -0500 Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-78117c8b6ccso718713485a.0 for ; Sun, 31 Dec 2023 13:00:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1704056416; x=1704661216; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gx5Gp3ZN3was01fuqRCdwquRS0vzzG9/+/KGXjA3ANg=; b=Psp6gfltC3f9/o1sIpvppqJk4G5xx0xb3vizcJJSv88XT/mPZx/q3PSClIYHadK+/0 5azQ1XpiR/KJiS59LXxvn73cv0CnWZTSLn3lKby6lKlRnXssmnTw8R7gH0jkMsW/d/Aw +Cv8YTddRdlYhH/EzINdLq8Ig2uGeCIIxMZV5SaJXvAnSRjdwCZ402eQ0CsP6BzTBH6B UU51EweyLTaMRD8cC1f12r3cHv+HZ5j4AUgdDFLWr1uSI3ZDDDOp+aJw/OXLTvwiuEB9 /ZWZ+BRqxRukhcrbRJHsEoeFtdiNMjIG1R/EnSuooQ5VHQN8gFCw6I+0RoSyLYwezSwh wDIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704056416; x=1704661216; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gx5Gp3ZN3was01fuqRCdwquRS0vzzG9/+/KGXjA3ANg=; b=DJZ8mnF0cTTn0H3kiHBA3KcE/o9aPu2K7+/1LgDpR0/+GwsF2q0J/43CEodrM2Ysb+ iXAhpOS2u2qu/o11iNXcVnOXDXXgjWiOUd61uA+R9bRbTmK3601fIac7fm6NVtPB49vw bOWFDsm+RAMBzNFLslmbRgaE0NPbfb0TlI0+VlPEyMa9afoijj23fQFlYdXPQ2OIXwpP lHV3XQsmZcrcfJIHSwZIGx7QMo9YBpR3/z/C1/uLrmFDJNyGlNcFSr+0PDHvFbTWtGWg UvduRj/8z3kNArhAlA0rxDhw8YZY38kAH8p5W/wIUJUMJyJSrEoFq2Wzlqoymfusq+N+ N9bA== X-Gm-Message-State: AOJu0YyZXOqH22Dr/eln56l0eRk+DTXxqasl1bzOdV6WvdoxcvQMGQKe RfHb0P1Wqr5g3T98p3CJe/V+WIcm2HCwlzmd5m5BzVL93q0= X-Google-Smtp-Source: AGHT+IEPFrTMQw2PT19k9dSAdDAC0QWydgGqvsidIku3o/85bHMVITuq8E0L+afFfiGyh6nQW6BWPQ== X-Received: by 2002:a05:620a:838e:b0:781:4233:3808 with SMTP id pb14-20020a05620a838e00b0078142333808mr19315741qkn.138.1704056416775; Sun, 31 Dec 2023 13:00:16 -0800 (PST) Received: from n36-186-108.byted.org. ([147.160.184.90]) by smtp.gmail.com with ESMTPSA id pb21-20020a05620a839500b007811da87cefsm8111750qkn.127.2023.12.31.13.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 13:00:16 -0800 (PST) From: Bryan Zhang To: qemu-devel@nongnu.org, farosas@suse.de, marcandre.lureau@redhat.com, peterx@redhat.com, quintela@redhat.com, peter.maydell@linaro.org, hao.xiang@bytedance.com Cc: bryan.zhang@bytedance.com Subject: [PATCH 5/5] migration: Add integration test for 'qatzip' compression method Date: Sun, 31 Dec 2023 20:58:04 +0000 Message-Id: <20231231205804.2366509-6-bryan.zhang@bytedance.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231231205804.2366509-1-bryan.zhang@bytedance.com> References: <20231231205804.2366509-1-bryan.zhang@bytedance.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=bryan.zhang@bytedance.com; helo=mail-qk1-x730.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 31 Dec 2023 16:22:09 -0500 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Adds an integration test for 'qatzip'. Signed-off-by: Bryan Zhang Signed-off-by: Hao Xiang --- tests/qtest/meson.build | 4 ++++ tests/qtest/migration-test.c | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 47dabf91d0..5931bd6418 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -302,6 +302,10 @@ if gnutls.found() endif endif +if qatzip.found() + migration_files += [qatzip] +endif + qtests = { 'bios-tables-test': [io, 'boot-sector.c', 'acpi-utils.c', 'tpm-emu.c'], 'cdrom-test': files('boot-sector.c'), diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index d520c587f7..f51bc4056f 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -35,6 +35,10 @@ # endif /* CONFIG_TASN1 */ #endif /* CONFIG_GNUTLS */ +#ifdef CONFIG_QATZIP +#include +#endif /* CONFIG_QATZIP */ + /* For dirty ring test; so far only x86_64 is supported */ #if defined(__linux__) && defined(HOST_X86_64) #include "linux/kvm.h" @@ -2572,6 +2576,15 @@ test_migrate_precopy_tcp_multifd_zstd_start(QTestState *from, } #endif /* CONFIG_ZSTD */ +#ifdef CONFIG_QATZIP +static void * +test_migrate_precopy_tcp_multifd_qatzip_start(QTestState *from, + QTestState *to) +{ + return test_migrate_precopy_tcp_multifd_start_common(from, to, "qatzip"); +} +#endif + static void test_multifd_tcp_none(void) { MigrateCommon args = { @@ -2607,6 +2620,17 @@ static void test_multifd_tcp_zstd(void) } #endif +#ifdef CONFIG_QATZIP +static void test_multifd_tcp_qatzip(void) +{ + MigrateCommon args = { + .listen_uri = "defer", + .start_hook = test_migrate_precopy_tcp_multifd_qatzip_start, + }; + test_precopy_common(&args); +} +#endif + #ifdef CONFIG_GNUTLS static void * test_migrate_multifd_tcp_tls_psk_start_match(QTestState *from, @@ -3480,6 +3504,19 @@ int main(int argc, char **argv) qtest_add_func("/migration/multifd/tcp/plain/zstd", test_multifd_tcp_zstd); #endif +#ifdef CONFIG_QATZIP + /* + * Use QATzip's qzInit() function as a runtime hardware check. + * Ideally there might be a cleaner way to probe for the presence of QAT. + */ + QzSession_T sess; + memset(&sess, 0, sizeof(QzSession_T)); + if (qzInit(&sess, 0) == QZ_OK) { + qzClose(&sess); + qtest_add_func("/migration/multifd/tcp/plain/qatzip", + test_multifd_tcp_qatzip); + } +#endif #ifdef CONFIG_GNUTLS qtest_add_func("/migration/multifd/tcp/tls/psk/match", test_multifd_tcp_tls_psk_match);