From nobody Sun Nov 24 12:01:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=quarantine dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1723681337; cv=none; d=zohomail.com; s=zohoarc; b=Tn+P4rWeQ4d+phOm8IJjVNxr9o+LWHs5v4LwSaCn4ZyKeygSvX8jfC1e3A8g3Oygdw1SG5guAjpvQifAszbQiKWAYiuhvMw2qJj6pSV1BpZjMEEzgP0mZIedNMjURNNyb3oVInZ5fUCfl9uObnlvmvTrvKVk+YBzVPp3Arr/Big= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723681337; 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=fSmtVkuTIatQvFoPy03zROe969GEcrj2NjmVN6S+iWs=; b=KXiReHj+KjGIqIF9a1KgTHcQH49Tv2mSdRBblWkoY5VtaJBiNO6wBNBq0LuPCtwi0giiKh/6Feq0teTo1qtPo7cixCu0m8B/Ltzig9zP62bPRNL1CRCyINJQeovSwUnojvIzYwjWNL/H5Zf9vegf4ft+ObzJelViwaCFMyI7o/E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1723681337462262.50035314927425; Wed, 14 Aug 2024 17:22:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1seOFG-0004qc-MK; Wed, 14 Aug 2024 20:21:38 -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 1seOFF-0004kL-OB for qemu-devel@nongnu.org; Wed, 14 Aug 2024 20:21:37 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1seOFD-0004Gh-Kd for qemu-devel@nongnu.org; Wed, 14 Aug 2024 20:21:37 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-70d18d4b94cso299887b3a.2 for ; Wed, 14 Aug 2024 17:21:34 -0700 (PDT) Received: from DY4X0N7X05.bytedance.net ([72.29.204.230]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f02faa03sm1961185ad.19.2024.08.14.17.21.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 14 Aug 2024 17:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1723681293; x=1724286093; 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=fSmtVkuTIatQvFoPy03zROe969GEcrj2NjmVN6S+iWs=; b=LBKy74yWT9DjrtRu2f1FwecCZph+eaUh2z0ewFU6NpSowkwWqGZQoXFXdTRWWwkjJJ 6+GLw8TXStdPWZpj/tYi29liEnKMn67LzuOa6aALJgBHqbkkW8Z4PjfmxCltx8o6LEn/ Q/6nir1g5SHXJQsPNIIOigcq9ddFHWzOBTTrhmDK/RENpy57jftFfRiv++ltaQFDEJyf yxtvO4wafUGz2ZSJoAbXBbECP2yE1B6WUGsFRRKYALxQB9ti2761sWNj/iGEEsdZf4ed cByIs2SocDNATfaN/B6s2dRgngEl/95KdUGq4GWERsfONfvd8mV63Xu/kGE6rfs8fLV/ Inbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723681293; x=1724286093; 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=fSmtVkuTIatQvFoPy03zROe969GEcrj2NjmVN6S+iWs=; b=tsd5sw0FG1ZrtONL96QCieXVhygTlx4Sg1apSagTozOMIVNZNRjudCuOVWsDGOWw3R JbJbPX+eIeSiVrKnldpdFMvnVt37Nuz/YJtaNyWfvsEC+NBLFGwnLoS3pNHzWmXjer4J /WPOInA1TpZxKVB4hosYJaRZ2GOBqYO0IvUBz2uLQJRNYbFy4VMipPNJZF2wN0WqBQ/N 32vr814Y1Ta8rGpws5k97/pELdIwU2IFWmfnq9sumlaEa7oRthi3pzhZ7iL3QHaI4TaW pdKdsfq9uZfhnCY1GiZPHqCRtlSUBXo16Oiu7BM5H8fBOXRBcLDwW1DXD2LfGu+90Y11 L4XA== X-Forwarded-Encrypted: i=1; AJvYcCXsgx7Ml2TvkwDRoIePg78BDAQc3QmoYm+kqGRG2Q0marFhmHIglhEgUA0gNcXN3/OnFOZihyWCjZqX3oUj7drK5W266lQ= X-Gm-Message-State: AOJu0YyjIHPn3dC4hZd+7+DPTsSKv5F8XEvW9n22NMwzH75mhh5bnrCX cssbMRl9UQE0RxawmoP4Q5UkXG6obmX28Np8IkHoP57OFkPVl0nICCLIv5rxYJg= X-Google-Smtp-Source: AGHT+IGPK8pMrJNY402wmsRFupyLUBPDQrD7p4vxujhAALbgPg85dGR7cQNXJaAhxKFbp/amvLK7OA== X-Received: by 2002:a05:6a20:d705:b0:1c0:e9dd:1197 with SMTP id adf61e73a8af0-1c8eaeaf752mr5703884637.22.1723681293018; Wed, 14 Aug 2024 17:21:33 -0700 (PDT) From: Yichen Wang To: Peter Xu , Fabiano Rosas , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Eric Blake , Markus Armbruster , qemu-devel@nongnu.org Cc: "Hao Xiang" , "Liu, Yuan1" , "Zou, Nanhai" , "Ho-Ren (Jack) Chuang" , "Yichen Wang" , Bryan Zhang Subject: [PATCH v7 3/5] migration: Add migration parameters for QATzip Date: Wed, 14 Aug 2024 17:21:22 -0700 Message-Id: <20240815002124.65384-4-yichen.wang@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240815002124.65384-1-yichen.wang@bytedance.com> References: <20240815002124.65384-1-yichen.wang@bytedance.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=2607:f8b0:4864:20::436; envelope-from=yichen.wang@bytedance.com; helo=mail-pf1-x436.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-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 @bytedance.com) X-ZM-MESSAGEID: 1723681338441116600 Content-Type: text/plain; charset="utf-8" From: Bryan Zhang Adds support for migration parameters to control QATzip compression level and to enable/disable software fallback when QAT hardware is unavailable. 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 Signed-off-by: Yichen Wang Acked-by: Markus Armbruster --- migration/migration-hmp-cmds.c | 4 ++++ migration/options.c | 34 ++++++++++++++++++++++++++++++++++ migration/options.h | 1 + qapi/migration.json | 18 ++++++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 7d608d26e1..28165cfc9e 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -576,6 +576,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDi= ct *qdict) p->has_multifd_zlib_level =3D true; visit_type_uint8(v, param, &p->multifd_zlib_level, &err); break; + case MIGRATION_PARAMETER_MULTIFD_QATZIP_LEVEL: + p->has_multifd_qatzip_level =3D true; + visit_type_uint8(v, param, &p->multifd_qatzip_level, &err); + break; case MIGRATION_PARAMETER_MULTIFD_ZSTD_LEVEL: p->has_multifd_zstd_level =3D true; visit_type_uint8(v, param, &p->multifd_zstd_level, &err); diff --git a/migration/options.c b/migration/options.c index 645f55003d..147cd2b8fd 100644 --- a/migration/options.c +++ b/migration/options.c @@ -55,6 +55,13 @@ #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 =20 @@ -123,6 +130,9 @@ Property migration_properties[] =3D { 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), @@ -787,6 +797,13 @@ int migrate_multifd_zlib_level(void) return s->parameters.multifd_zlib_level; } =20 +int migrate_multifd_qatzip_level(void) +{ + MigrationState *s =3D migrate_get_current(); + + return s->parameters.multifd_qatzip_level; +} + int migrate_multifd_zstd_level(void) { MigrationState *s =3D migrate_get_current(); @@ -892,6 +909,8 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->multifd_compression =3D s->parameters.multifd_compression; params->has_multifd_zlib_level =3D true; params->multifd_zlib_level =3D s->parameters.multifd_zlib_level; + params->has_multifd_qatzip_level =3D true; + params->multifd_qatzip_level =3D s->parameters.multifd_qatzip_level; params->has_multifd_zstd_level =3D true; params->multifd_zstd_level =3D s->parameters.multifd_zstd_level; params->has_xbzrle_cache_size =3D true; @@ -946,6 +965,7 @@ void migrate_params_init(MigrationParameters *params) params->has_multifd_channels =3D true; params->has_multifd_compression =3D true; params->has_multifd_zlib_level =3D true; + params->has_multifd_qatzip_level =3D true; params->has_multifd_zstd_level =3D true; params->has_xbzrle_cache_size =3D true; params->has_max_postcopy_bandwidth =3D true; @@ -1038,6 +1058,14 @@ bool migrate_params_check(MigrationParameters *param= s, Error **errp) return false; } =20 + 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_lev= el", + "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= ", @@ -1195,6 +1223,9 @@ static void migrate_params_test_apply(MigrateSetParam= eters *params, if (params->has_multifd_compression) { dest->multifd_compression =3D params->multifd_compression; } + if (params->has_multifd_qatzip_level) { + dest->multifd_qatzip_level =3D params->multifd_qatzip_level; + } if (params->has_multifd_zlib_level) { dest->multifd_zlib_level =3D params->multifd_zlib_level; } @@ -1315,6 +1346,9 @@ static void migrate_params_apply(MigrateSetParameters= *params, Error **errp) if (params->has_multifd_compression) { s->parameters.multifd_compression =3D params->multifd_compression; } + if (params->has_multifd_qatzip_level) { + s->parameters.multifd_qatzip_level =3D params->multifd_qatzip_leve= l; + } if (params->has_multifd_zlib_level) { s->parameters.multifd_zlib_level =3D params->multifd_zlib_level; } diff --git a/migration/options.h b/migration/options.h index a2397026db..a0bd6edc06 100644 --- a/migration/options.h +++ b/migration/options.h @@ -78,6 +78,7 @@ uint64_t migrate_max_postcopy_bandwidth(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 7324571e92..279a705cae 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -792,6 +792,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. (Since 9.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 @@ -852,6 +857,7 @@ 'xbzrle-cache-size', 'max-postcopy-bandwidth', 'max-cpu-throttle', 'multifd-compression', 'multifd-zlib-level', 'multifd-zstd-level', + 'multifd-qatzip-level', 'block-bitmap-mapping', { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable']= }, 'vcpu-dirty-limit', @@ -967,6 +973,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. (Since 9.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 @@ -1040,6 +1051,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', @@ -1171,6 +1183,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. (Since 9.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 @@ -1241,6 +1258,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', --=20 Yichen Wang