From nobody Wed Nov 27 09:40:47 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=1699940688; cv=none; d=zohomail.com; s=zohoarc; b=DxEO7NyrMkJFPzmsY099p6tfEBIBAkuHFT1CT25UJb0dsp/hGE8uQ20+RmvCK3r70vEXddtGEEOIkoVmDzPGTPd6yYHxsUoklvVXs9j5ZEnHPoy8l7acpAdVRzThPpvGS0QIdf8+0oLt1qhteCB7L/gF9Z5NTg/b3KpmnrnwtKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699940688; 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=UC/+IR5Y7dIjrKdVazsg+msPhpgomaB++LU+9G8M++8=; b=P45zgg45TXXUgcx78MROvS8ZNkshi3T/aMeHzrujYsbh9FDZyUo9Ui/qhGjykbi4+xdm/XRoElUKApYLDJp6wMU0aXVdYkltGvBaz5FlZymgIIV5m3IHCe3f3J3O0OloaszhURkIUBHbxRkeCxhC0m6fCKoutVhFLWWMEB8G+Xw= 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 16999406880533.5305441109625235; Mon, 13 Nov 2023 21:44:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r2mBn-0007Io-7N; Tue, 14 Nov 2023 00:42:19 -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 1r2mBV-0007Fy-Lc for qemu-devel@nongnu.org; Tue, 14 Nov 2023 00:42:03 -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 1r2mBT-0001U3-UH for qemu-devel@nongnu.org; Tue, 14 Nov 2023 00:42:01 -0500 Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-7789a4c01ddso346439085a.1 for ; Mon, 13 Nov 2023 21:41:59 -0800 (PST) Received: from n231-230-216.byted.org ([130.44.212.104]) by smtp.gmail.com with ESMTPSA id w2-20020a05620a094200b0077891d2d12dsm2400367qkw.43.2023.11.13.21.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 21:41:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1699940519; x=1700545319; 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=UC/+IR5Y7dIjrKdVazsg+msPhpgomaB++LU+9G8M++8=; b=YmfmMnqpEgzggjOjnb2yoyOWMIIfigoQCiPuLQIsUyiDkMe/fLx9MsQUX7nF/7+x0j YDC2pZc/lLQtJaH4In79G/4VuxxCUenVziCPnaT+cwK95qIcZyuDQlSK4Ie9a8YslX+s 6xaX29hZurDn3Z2jrffgXLWqhTDd4HJovmG+j38ZK5n0s1HXAy4BA9PqZpbedMvjCdnw Nt4MOVkgaFFrb09qPHlHA3PtxUhZ5g5fAMxxuPiy3lX4zmYX/C3ePrZRK3RluhroWLtI kSpKawVyceJsekjwb3r8qkKF6PhkyJvdDkghRijZYBn8FQJtEErB3ih+v0ebPJYsdo/p OfyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699940519; x=1700545319; 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=UC/+IR5Y7dIjrKdVazsg+msPhpgomaB++LU+9G8M++8=; b=WF1F/3xiKtzvA3X01ir1mRsD8BVgjEqspAcuVIRmmHWul84vOJu5MNAR1E3qF9xo75 kogzA12nMNxi7oW0bhj+d34Otc63bnLce/quYFCIUCme1mC1yAipPVojVxXtBEZYnas4 S8APRcu8vDdacsX5bVisswmpKyXfICXtbOYnjc03T5zRjDbiQhlLQnAWPrQTeL8TJ3pb 0KkLbtkbGWWApQGRWZ/efWz2/ibN2WazSsvozOwO6wphl3DTdNX2twJuJQgVY6A1NlTO 7fBxSAie6JITRqtXQHW0eXzUkZ1MB1It4ocgVJEWWXR3SbfFDN9hM0e9oau8v74zkDi5 6QoQ== X-Gm-Message-State: AOJu0YwV7gAsUbbJia2eWgv4tk/LPgvcgmHAAf5YrzkH0ER4Kf1fAYmV VJZieTmlkHOjlBSBChKFXKtwPw== X-Google-Smtp-Source: AGHT+IGBzP24lWpYXIa/JTY78ljFJlV021h5ohwVPYqsIhmF/i4pSWOcFdAzLFj5FkNx+ddOIzu3Iw== X-Received: by 2002:a05:620a:9493:b0:77a:605:d693 with SMTP id sn19-20020a05620a949300b0077a0605d693mr959550qkn.22.1699940518794; Mon, 13 Nov 2023 21:41:58 -0800 (PST) From: Hao Xiang To: farosas@suse.de, peter.maydell@linaro.org, quintela@redhat.com, peterx@redhat.com, marcandre.lureau@redhat.com, bryan.zhang@bytedance.com, qemu-devel@nongnu.org Cc: Hao Xiang Subject: [PATCH v2 15/20] migration/multifd: Add test hook to set normal page ratio. Date: Tue, 14 Nov 2023 05:40:27 +0000 Message-Id: <20231114054032.1192027-16-hao.xiang@bytedance.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231114054032.1192027-1-hao.xiang@bytedance.com> References: <20231114054032.1192027-1-hao.xiang@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::72d; envelope-from=hao.xiang@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-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: 1699940690058100003 Content-Type: text/plain; charset="utf-8" Multifd sender thread performs zero page checking. If a page is a zero page, only the page's metadata is sent to the receiver. If a page is a normal page, the entire page's content is sent to the receiver. This change adds a test hook to set the normal page ratio. A zero page will be forced to be sent as a normal page. This is useful for live migration performance analysis and optimization. Signed-off-by: Hao Xiang --- migration/options.c | 31 +++++++++++++++++++++++++++++++ migration/options.h | 1 + qapi/migration.json | 18 +++++++++++++++--- 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/migration/options.c b/migration/options.c index 6e424b5d63..e7f1e2df24 100644 --- a/migration/options.c +++ b/migration/options.c @@ -79,6 +79,11 @@ #define DEFAULT_MIGRATE_ANNOUNCE_ROUNDS 5 #define DEFAULT_MIGRATE_ANNOUNCE_STEP 100 =20 +/* + * Parameter for multifd normal page test hook. + */ +#define DEFAULT_MIGRATE_MULTIFD_NORMAL_PAGE_RATIO 101 + #define DEFINE_PROP_MIG_CAP(name, x) \ DEFINE_PROP_BOOL(name, MigrationState, capabilities[x], false) =20 @@ -181,6 +186,9 @@ Property migration_properties[] =3D { MIG_MODE_NORMAL), DEFINE_PROP_STRING("multifd-dsa-accel", MigrationState, parameters.multifd_dsa_accel), + DEFINE_PROP_UINT8("multifd-normal-page-ratio", MigrationState, + parameters.multifd_normal_page_ratio, + DEFAULT_MIGRATE_MULTIFD_NORMAL_PAGE_RATIO), =20 /* Migration capabilities */ DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), @@ -860,6 +868,12 @@ int migrate_multifd_channels(void) return s->parameters.multifd_channels; } =20 +uint8_t migrate_multifd_normal_page_ratio(void) +{ + MigrationState *s =3D migrate_get_current(); + return s->parameters.multifd_normal_page_ratio; +} + MultiFDCompression migrate_multifd_compression(void) { MigrationState *s =3D migrate_get_current(); @@ -1258,6 +1272,14 @@ bool migrate_params_check(MigrationParameters *param= s, Error **errp) return false; } =20 + if (params->has_multifd_normal_page_ratio && + params->multifd_normal_page_ratio > 100) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, + "multifd_normal_page_ratio", + "a value between 0 and 100"); + return false; + } + return true; } =20 @@ -1378,6 +1400,11 @@ static void migrate_params_test_apply(MigrateSetPara= meters *params, assert(params->multifd_dsa_accel->type =3D=3D QTYPE_QSTRING); dest->multifd_dsa_accel =3D params->multifd_dsa_accel->u.s; } + + if (params->has_multifd_normal_page_ratio) { + dest->has_multifd_normal_page_ratio =3D true; + dest->multifd_normal_page_ratio =3D params->multifd_normal_page_ra= tio; + } } =20 static void migrate_params_apply(MigrateSetParameters *params, Error **err= p) @@ -1528,6 +1555,10 @@ static void migrate_params_apply(MigrateSetParameter= s *params, Error **errp) assert(params->multifd_dsa_accel->type =3D=3D QTYPE_QSTRING); s->parameters.multifd_dsa_accel =3D g_strdup(params->multifd_dsa_a= ccel->u.s); } + + if (params->has_multifd_normal_page_ratio) { + s->parameters.multifd_normal_page_ratio =3D params->multifd_normal= _page_ratio; + } } =20 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) diff --git a/migration/options.h b/migration/options.h index 56100961a9..21e3e7b0cf 100644 --- a/migration/options.h +++ b/migration/options.h @@ -95,6 +95,7 @@ const char *migrate_tls_creds(void); const char *migrate_tls_hostname(void); uint64_t migrate_xbzrle_cache_size(void); const char *migrate_multifd_dsa_accel(void); +uint8_t migrate_multifd_normal_page_ratio(void); =20 /* parameters setters */ =20 diff --git a/qapi/migration.json b/qapi/migration.json index a8e3b66d6f..bb876c8325 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -882,6 +882,9 @@ # @multifd-dsa-accel: If enabled, use DSA accelerator offloading for # certain memory operations. (since 8.2) # +# @multifd-normal-page-ratio: Test hook setting the normal page ratio. +# (Since 8.2) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -915,7 +918,8 @@ 'block-bitmap-mapping', { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable']= }, 'vcpu-dirty-limit', - 'mode'] } + 'mode', + 'multifd-normal-page-ratio'] } =20 ## # @MigrateSetParameters: @@ -1073,6 +1077,9 @@ # @multifd-dsa-accel: If enabled, use DSA accelerator offloading for # certain memory operations. (since 8.2) # +# @multifd-normal-page-ratio: Test hook setting the normal page ratio. +# (Since 8.2) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -1127,7 +1134,8 @@ 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', '*mode': 'MigMode', - '*multifd-dsa-accel': 'StrOrNull'} } + '*multifd-dsa-accel': 'StrOrNull', + '*multifd-normal-page-ratio': 'uint8'} } =20 ## # @migrate-set-parameters: @@ -1305,6 +1313,9 @@ # @multifd-dsa-accel: If enabled, use DSA accelerator offloading for # certain memory operations. (since 8.2) # +# @multifd-normal-page-ratio: Test hook setting the normal page ratio. +# (Since 8.2) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -1356,7 +1367,8 @@ 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', '*mode': 'MigMode', - '*multifd-dsa-accel': 'str'} } + '*multifd-dsa-accel': 'str', + '*multifd-normal-page-ratio': 'uint8'} } =20 ## # @query-migrate-parameters: --=20 2.30.2