From nobody Tue Nov 26 08:39:02 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=1708977572; cv=none; d=zohomail.com; s=zohoarc; b=CIpud8MWfloY8zohQO7b4C5Rsy19sGy47ryiI/xmBM6/d7WCaz/Cu4lAfUN+Fbbac0wkmk5yqqcmHBdAqnpNn2p7v2D2SWEXeUdko7sM84cZ81lB0zNZNYCTpXuxle7udg7GYfB+yIjpffZ1W/XBMIsUj835GDZMGk6jC3AkQG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708977572; 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=ZgDjuALvbSevFWEfp0Xrz/jY7qt4RLoP+bPDhImpo/k=; b=a7saYEioyUnTbwdrtfHIpSqK2V5nCYi91LklSgD7gifShGT6F5KKaGrl+95eyvUjHSoQxyAWwHyV1rROcZc+SuevGYpCh7srntH2D3xsdpPqzRtwNtD446oyyvx0NP+yYWvqv1fVOoDN263EGAJKe6p45IF8Mz+P+UzWEyODdm8= 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 1708977572368905.6322417702992; Mon, 26 Feb 2024 11:59:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1reh6u-00012i-Et; Mon, 26 Feb 2024 14:58:00 -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 1reh6m-0000yj-Tm for qemu-devel@nongnu.org; Mon, 26 Feb 2024 14:57:53 -0500 Received: from mail-vk1-xa30.google.com ([2607:f8b0:4864:20::a30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1reh6k-0004tk-L0 for qemu-devel@nongnu.org; Mon, 26 Feb 2024 14:57:52 -0500 Received: by mail-vk1-xa30.google.com with SMTP id 71dfb90a1353d-4cb26623d0aso809017e0c.1 for ; Mon, 26 Feb 2024 11:57:49 -0800 (PST) Received: from n231-230-216.byted.org ([130.44.212.95]) by smtp.gmail.com with ESMTPSA id ej5-20020a056122270500b004ca3dc45886sm712738vkb.47.2024.02.26.11.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 11:57:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1708977469; x=1709582269; 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=ZgDjuALvbSevFWEfp0Xrz/jY7qt4RLoP+bPDhImpo/k=; b=VsbAA6lYtbS7rugZBrrV+RWXL+77F4qc8Fs1eMiazc1Vs0jh/6R9nLhKXg6exjeZg5 M/DMxQBaqNsXyDs94hIIToOzvjoRvNC5NG5hhDJo3GwDSEMqCvHhy72NH0msB62SGi9I PYDFi9Q4AJtOMgVfK1DjKV++cniLR3HRrvCR59IXAPEFU3YwXdoGeIYT6BZ+GKjRqDJg C9WK5Dy/NOTrqnS2MHSajQQGUkWis5/ZEvyXzg7AI9Y19CaTmi5aq639mlOg28j8ZW3K 6SOK8bldE7GVPX6KQN34+ZYgtFmlBvO4yBbEzW+y9Ez+ugdtDmhC7d9arUSe1A89TdyE kt+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708977469; x=1709582269; 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=ZgDjuALvbSevFWEfp0Xrz/jY7qt4RLoP+bPDhImpo/k=; b=U0I0y5BhKHW2eMe2ysLbVvOFwFGDFJUCZnEw9TQtwWsQbTBWXm7Ihbd2MH790Yj/vP fnrBeQYGPN6JqJEMKFB0ChwGfBqhjthyz2A7ECEFSF3GSA5/7hTNNMCCzUJxghfTyoZc KsKfA3LL/+krFKS6Gpum1YRfm1WXF69uNYLntKzxF/+z2eJZWGblF9pa1Qr4qKi/y2J7 ELlQ7g2iscem/vh+h5AG5/HBPHMqYlQOOsKpCy8GAAjKJjgA5ehYpK57XTDKZzucdYBe t9PUBnQRSY712+tp4RfbDgWnwymDnh1KhpnI9WYHoWMnkxZ+Pd0mEcZ4/rf+i71dsvit NypQ== X-Forwarded-Encrypted: i=1; AJvYcCUfQuiJ1NDoyYIFz8GWyUj3sweUSCRbTkBDJgqA60Dgc49IT6VdPr2if6EbL4JU/fA0Cltf4Ud5GoUwm7554HGOrad6/hk= X-Gm-Message-State: AOJu0YzNcHCHVCFIyfzmH9deB89E5KvQlkNjN2FOt4Q4kL8RXGnt1P/O a/nUVTLNmy4wa95BNe3jca+wzuPt3xthO6UrIc31HsoT8BSXBjgXkxBu3Sqreqo= X-Google-Smtp-Source: AGHT+IF96s81tLbr+OkLEguOKeJ2SwaPlPN5oDO+/nB5jtBRiMfnlJsTGNwBA86UIrNMiPycO6u+KQ== X-Received: by 2002:a1f:48c3:0:b0:4c9:98f8:83d7 with SMTP id v186-20020a1f48c3000000b004c998f883d7mr4354080vka.0.1708977469029; Mon, 26 Feb 2024 11:57:49 -0800 (PST) From: Hao Xiang To: pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, peterx@redhat.com, farosas@suse.de, eblake@redhat.com, armbru@redhat.com, thuth@redhat.com, lvivier@redhat.com, jdenemar@redhat.com, marcel.apfelbaum@gmail.com, philmd@linaro.org, wangyanan55@huawei.com, qemu-devel@nongnu.org Cc: Hao Xiang Subject: [PATCH v3 1/7] migration/multifd: Add new migration option zero-page-detection. Date: Mon, 26 Feb 2024 19:56:48 +0000 Message-Id: <20240226195654.934709-2-hao.xiang@bytedance.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240226195654.934709-1-hao.xiang@bytedance.com> References: <20240226195654.934709-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::a30; envelope-from=hao.xiang@bytedance.com; helo=mail-vk1-xa30.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: 1708977573653100002 Content-Type: text/plain; charset="utf-8" This new parameter controls where the zero page checking is running. 1. If this parameter is set to 'legacy', zero page checking is done in the migration main thread. 2. If this parameter is set to 'none', zero page checking is disabled. Signed-off-by: Hao Xiang --- hw/core/qdev-properties-system.c | 10 ++++++++++ include/hw/qdev-properties-system.h | 4 ++++ migration/migration-hmp-cmds.c | 9 +++++++++ migration/options.c | 21 ++++++++++++++++++++ migration/options.h | 1 + migration/ram.c | 4 ++++ qapi/migration.json | 30 ++++++++++++++++++++++++++--- 7 files changed, 76 insertions(+), 3 deletions(-) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index 1a396521d5..228e685f52 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -679,6 +679,16 @@ const PropertyInfo qdev_prop_mig_mode =3D { .set_default_value =3D qdev_propinfo_set_default_value_enum, }; =20 +const PropertyInfo qdev_prop_zero_page_detection =3D { + .name =3D "ZeroPageDetection", + .description =3D "zero_page_detection values, " + "none,legacy", + .enum_table =3D &ZeroPageDetection_lookup, + .get =3D qdev_propinfo_get_enum, + .set =3D qdev_propinfo_set_enum, + .set_default_value =3D qdev_propinfo_set_default_value_enum, +}; + /* --- Reserved Region --- */ =20 /* diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properti= es-system.h index 06c359c190..839b170235 100644 --- a/include/hw/qdev-properties-system.h +++ b/include/hw/qdev-properties-system.h @@ -8,6 +8,7 @@ extern const PropertyInfo qdev_prop_macaddr; extern const PropertyInfo qdev_prop_reserved_region; extern const PropertyInfo qdev_prop_multifd_compression; extern const PropertyInfo qdev_prop_mig_mode; +extern const PropertyInfo qdev_prop_zero_page_detection; extern const PropertyInfo qdev_prop_losttickpolicy; extern const PropertyInfo qdev_prop_blockdev_on_error; extern const PropertyInfo qdev_prop_bios_chs_trans; @@ -47,6 +48,9 @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_l= ist; #define DEFINE_PROP_MIG_MODE(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_mig_mode, \ MigMode) +#define DEFINE_PROP_ZERO_PAGE_DETECTION(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_zero_page_detection, \ + ZeroPageDetection) #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ LostTickPolicy) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 99b49df5dd..7e96ae6ffd 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -344,6 +344,11 @@ void hmp_info_migrate_parameters(Monitor *mon, const Q= Dict *qdict) monitor_printf(mon, "%s: %s\n", MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESSION= ), MultiFDCompression_str(params->multifd_compression)); + assert(params->has_zero_page_detection); + monitor_printf(mon, "%s: %s\n", + MigrationParameter_str(MIGRATION_PARAMETER_ZERO_PAGE_DETECTION= ), + qapi_enum_lookup(&ZeroPageDetection_lookup, + params->zero_page_detection)); monitor_printf(mon, "%s: %" PRIu64 " bytes\n", MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE), params->xbzrle_cache_size); @@ -634,6 +639,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDi= ct *qdict) p->has_multifd_zstd_level =3D true; visit_type_uint8(v, param, &p->multifd_zstd_level, &err); break; + case MIGRATION_PARAMETER_ZERO_PAGE_DETECTION: + p->has_zero_page_detection =3D true; + visit_type_ZeroPageDetection(v, param, &p->zero_page_detection, &e= rr); + break; case MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE: p->has_xbzrle_cache_size =3D true; if (!visit_type_size(v, param, &cache_size, &err)) { diff --git a/migration/options.c b/migration/options.c index 3e3e0b93b4..3c603391b0 100644 --- a/migration/options.c +++ b/migration/options.c @@ -179,6 +179,9 @@ Property migration_properties[] =3D { DEFINE_PROP_MIG_MODE("mode", MigrationState, parameters.mode, MIG_MODE_NORMAL), + DEFINE_PROP_ZERO_PAGE_DETECTION("zero-page-detection", MigrationState, + parameters.zero_page_detection, + ZERO_PAGE_DETECTION_LEGACY), =20 /* Migration capabilities */ DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE), @@ -903,6 +906,13 @@ uint64_t migrate_xbzrle_cache_size(void) return s->parameters.xbzrle_cache_size; } =20 +ZeroPageDetection migrate_zero_page_detection(void) +{ + MigrationState *s =3D migrate_get_current(); + + return s->parameters.zero_page_detection; +} + /* parameter setters */ =20 void migrate_set_block_incremental(bool value) @@ -1013,6 +1023,8 @@ MigrationParameters *qmp_query_migrate_parameters(Err= or **errp) params->vcpu_dirty_limit =3D s->parameters.vcpu_dirty_limit; params->has_mode =3D true; params->mode =3D s->parameters.mode; + params->has_zero_page_detection =3D true; + params->zero_page_detection =3D s->parameters.zero_page_detection; =20 return params; } @@ -1049,6 +1061,7 @@ void migrate_params_init(MigrationParameters *params) params->has_x_vcpu_dirty_limit_period =3D true; params->has_vcpu_dirty_limit =3D true; params->has_mode =3D true; + params->has_zero_page_detection =3D true; } =20 /* @@ -1350,6 +1363,10 @@ static void migrate_params_test_apply(MigrateSetPara= meters *params, if (params->has_mode) { dest->mode =3D params->mode; } + + if (params->has_zero_page_detection) { + dest->zero_page_detection =3D params->zero_page_detection; + } } =20 static void migrate_params_apply(MigrateSetParameters *params, Error **err= p) @@ -1494,6 +1511,10 @@ static void migrate_params_apply(MigrateSetParameter= s *params, Error **errp) if (params->has_mode) { s->parameters.mode =3D params->mode; } + + if (params->has_zero_page_detection) { + s->parameters.zero_page_detection =3D params->zero_page_detection; + } } =20 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) diff --git a/migration/options.h b/migration/options.h index 246c160aee..b7c4fb3861 100644 --- a/migration/options.h +++ b/migration/options.h @@ -93,6 +93,7 @@ const char *migrate_tls_authz(void); const char *migrate_tls_creds(void); const char *migrate_tls_hostname(void); uint64_t migrate_xbzrle_cache_size(void); +ZeroPageDetection migrate_zero_page_detection(void); =20 /* parameters setters */ =20 diff --git a/migration/ram.c b/migration/ram.c index 4649a81204..67035fb4b1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1123,6 +1123,10 @@ static int save_zero_page(RAMState *rs, PageSearchSt= atus *pss, QEMUFile *file =3D pss->pss_channel; int len =3D 0; =20 + if (migrate_zero_page_detection() =3D=3D ZERO_PAGE_DETECTION_NONE) { + return 0; + } + if (!buffer_is_zero(p, TARGET_PAGE_SIZE)) { return 0; } diff --git a/qapi/migration.json b/qapi/migration.json index 5a565d9b8d..1e66272f8f 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -653,6 +653,18 @@ { 'enum': 'MigMode', 'data': [ 'normal', 'cpr-reboot' ] } =20 +## +# @ZeroPageDetection: +# +# @none: Do not perform zero page checking. +# +# @legacy: Perform zero page checking from main migration thread. +# +# Since: 9.0 +## +{ 'enum': 'ZeroPageDetection', + 'data': [ 'none', 'legacy' ] } + ## # @BitmapMigrationBitmapAliasTransform: # @@ -874,6 +886,9 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @zero-page-detection: Whether and how to detect zero pages. More details +# see description in @ZeroPageDetection. Default is 'legacy'. (since = 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -907,7 +922,8 @@ 'block-bitmap-mapping', { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable']= }, 'vcpu-dirty-limit', - 'mode'] } + 'mode', + 'zero-page-detection'] } =20 ## # @MigrateSetParameters: @@ -1066,6 +1082,9 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @zero-page-detection: Whether and how to detect zero pages. More details +# see description in @ZeroPageDetection. Default is 'legacy'. (since = 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -1119,7 +1138,8 @@ '*x-vcpu-dirty-limit-period': { 'type': 'uint64', 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', - '*mode': 'MigMode'} } + '*mode': 'MigMode', + '*zero-page-detection': 'ZeroPageDetection'} } =20 ## # @migrate-set-parameters: @@ -1294,6 +1314,9 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @zero-page-detection: Whether and how to detect zero pages. More details +# see description in @ZeroPageDetection. Default is 'legacy'. (since = 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -1344,7 +1367,8 @@ '*x-vcpu-dirty-limit-period': { 'type': 'uint64', 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', - '*mode': 'MigMode'} } + '*mode': 'MigMode', + '*zero-page-detection': 'ZeroPageDetection'} } =20 ## # @query-migrate-parameters: --=20 2.30.2