[PATCH v2 12/20] migration/multifd: Add new migration option for multifd DSA offloading.

Hao Xiang posted 20 patches 1 year ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Thomas Huth <thuth@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Juan Quintela <quintela@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, Leonardo Bras <leobras@redhat.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Laurent Vivier <lvivier@redhat.com>
There is a newer version of this series
[PATCH v2 12/20] migration/multifd: Add new migration option for multifd DSA offloading.
Posted by Hao Xiang 1 year ago
Intel DSA offloading is an optional feature that turns on if
proper hardware and software stack is available. To turn on
DSA offloading in multifd live migration:

multifd-dsa-accel="[dsa_dev_path1] ] [dsa_dev_path2] ... [dsa_dev_pathX]"

This feature is turned off by default.

Signed-off-by: Hao Xiang <hao.xiang@bytedance.com>
---
 migration/migration-hmp-cmds.c |  8 ++++++++
 migration/options.c            | 28 ++++++++++++++++++++++++++++
 migration/options.h            |  1 +
 qapi/migration.json            | 17 ++++++++++++++---
 scripts/meson-buildoptions.sh  |  6 +++---
 5 files changed, 54 insertions(+), 6 deletions(-)

diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
index 86ae832176..d9451744dd 100644
--- a/migration/migration-hmp-cmds.c
+++ b/migration/migration-hmp-cmds.c
@@ -353,6 +353,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
         monitor_printf(mon, "%s: '%s'\n",
             MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ),
             params->tls_authz);
+        monitor_printf(mon, "%s: %s\n",
+            MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_DSA_ACCEL),
+            params->multifd_dsa_accel);
 
         if (params->has_block_bitmap_mapping) {
             const BitmapMigrationNodeAliasList *bmnal;
@@ -615,6 +618,11 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
         p->has_block_incremental = true;
         visit_type_bool(v, param, &p->block_incremental, &err);
         break;
+    case MIGRATION_PARAMETER_MULTIFD_DSA_ACCEL:
+        p->multifd_dsa_accel = g_new0(StrOrNull, 1);
+        p->multifd_dsa_accel->type = QTYPE_QSTRING;
+        visit_type_str(v, param, &p->multifd_dsa_accel->u.s, &err);
+        break;
     case MIGRATION_PARAMETER_MULTIFD_CHANNELS:
         p->has_multifd_channels = true;
         visit_type_uint8(v, param, &p->multifd_channels, &err);
diff --git a/migration/options.c b/migration/options.c
index 97d121d4d7..6e424b5d63 100644
--- a/migration/options.c
+++ b/migration/options.c
@@ -179,6 +179,8 @@ Property migration_properties[] = {
     DEFINE_PROP_MIG_MODE("mode", MigrationState,
                       parameters.mode,
                       MIG_MODE_NORMAL),
+    DEFINE_PROP_STRING("multifd-dsa-accel", MigrationState,
+                       parameters.multifd_dsa_accel),
 
     /* Migration capabilities */
     DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE),
@@ -901,6 +903,13 @@ const char *migrate_tls_creds(void)
     return s->parameters.tls_creds;
 }
 
+const char *migrate_multifd_dsa_accel(void)
+{
+    MigrationState *s = migrate_get_current();
+
+    return s->parameters.multifd_dsa_accel;
+}
+
 const char *migrate_tls_hostname(void)
 {
     MigrationState *s = migrate_get_current();
@@ -1025,6 +1034,7 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
     params->vcpu_dirty_limit = s->parameters.vcpu_dirty_limit;
     params->has_mode = true;
     params->mode = s->parameters.mode;
+    params->multifd_dsa_accel = s->parameters.multifd_dsa_accel;
 
     return params;
 }
@@ -1033,6 +1043,7 @@ void migrate_params_init(MigrationParameters *params)
 {
     params->tls_hostname = g_strdup("");
     params->tls_creds = g_strdup("");
+    params->multifd_dsa_accel = g_strdup("");
 
     /* Set has_* up only for parameter checks */
     params->has_compress_level = true;
@@ -1362,6 +1373,11 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
     if (params->has_mode) {
         dest->mode = params->mode;
     }
+
+    if (params->multifd_dsa_accel) {
+        assert(params->multifd_dsa_accel->type == QTYPE_QSTRING);
+        dest->multifd_dsa_accel = params->multifd_dsa_accel->u.s;
+    }
 }
 
 static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
@@ -1506,6 +1522,12 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
     if (params->has_mode) {
         s->parameters.mode = params->mode;
     }
+
+    if (params->multifd_dsa_accel) {
+        g_free(s->parameters.multifd_dsa_accel);
+        assert(params->multifd_dsa_accel->type == QTYPE_QSTRING);
+        s->parameters.multifd_dsa_accel = g_strdup(params->multifd_dsa_accel->u.s);
+    }
 }
 
 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
@@ -1531,6 +1553,12 @@ void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
         params->tls_authz->type = QTYPE_QSTRING;
         params->tls_authz->u.s = strdup("");
     }
+    if (params->multifd_dsa_accel
+        && params->multifd_dsa_accel->type == QTYPE_QNULL) {
+        qobject_unref(params->multifd_dsa_accel->u.n);
+        params->multifd_dsa_accel->type = QTYPE_QSTRING;
+        params->multifd_dsa_accel->u.s = strdup("");
+    }
 
     migrate_params_test_apply(params, &tmp);
 
diff --git a/migration/options.h b/migration/options.h
index c901eb57c6..56100961a9 100644
--- a/migration/options.h
+++ b/migration/options.h
@@ -94,6 +94,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);
+const char *migrate_multifd_dsa_accel(void);
 
 /* parameters setters */
 
diff --git a/qapi/migration.json b/qapi/migration.json
index 9783289bfc..a8e3b66d6f 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -879,6 +879,9 @@
 # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
 #        (Since 8.2)
 #
+# @multifd-dsa-accel: If enabled, use DSA accelerator offloading for
+#                     certain memory operations. (since 8.2)
+#
 # Features:
 #
 # @deprecated: Member @block-incremental is deprecated.  Use
@@ -902,7 +905,7 @@
            'cpu-throttle-initial', 'cpu-throttle-increment',
            'cpu-throttle-tailslow',
            'tls-creds', 'tls-hostname', 'tls-authz', 'max-bandwidth',
-           'avail-switchover-bandwidth', 'downtime-limit',
+           'avail-switchover-bandwidth', 'downtime-limit', 'multifd-dsa-accel',
            { 'name': 'x-checkpoint-delay', 'features': [ 'unstable' ] },
            { 'name': 'block-incremental', 'features': [ 'deprecated' ] },
            'multifd-channels',
@@ -1067,6 +1070,9 @@
 # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
 #        (Since 8.2)
 #
+# @multifd-dsa-accel: If enabled, use DSA accelerator offloading for
+#                     certain memory operations. (since 8.2)
+#
 # Features:
 #
 # @deprecated: Member @block-incremental is deprecated.  Use
@@ -1120,7 +1126,8 @@
             '*x-vcpu-dirty-limit-period': { 'type': 'uint64',
                                             'features': [ 'unstable' ] },
             '*vcpu-dirty-limit': 'uint64',
-            '*mode': 'MigMode'} }
+            '*mode': 'MigMode',
+            '*multifd-dsa-accel': 'StrOrNull'} }
 
 ##
 # @migrate-set-parameters:
@@ -1295,6 +1302,9 @@
 # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
 #        (Since 8.2)
 #
+# @multifd-dsa-accel: If enabled, use DSA accelerator offloading for
+#                     certain memory operations. (since 8.2)
+#
 # Features:
 #
 # @deprecated: Member @block-incremental is deprecated.  Use
@@ -1345,7 +1355,8 @@
             '*x-vcpu-dirty-limit-period': { 'type': 'uint64',
                                             'features': [ 'unstable' ] },
             '*vcpu-dirty-limit': 'uint64',
-            '*mode': 'MigMode'} }
+            '*mode': 'MigMode',
+            '*multifd-dsa-accel': 'str'} }
 
 ##
 # @query-migrate-parameters:
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index bf139e3fb4..35222ab63e 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -32,6 +32,7 @@ meson_options_help() {
   printf "%s\n" '  --enable-debug-stack-usage'
   printf "%s\n" '                           measure coroutine stack usage'
   printf "%s\n" '  --enable-debug-tcg       TCG debugging'
+  printf "%s\n" '  --enable-enqcmd          MENQCMD optimizations'
   printf "%s\n" '  --enable-fdt[=CHOICE]    Whether and how to find the libfdt library'
   printf "%s\n" '                           (choices: auto/disabled/enabled/internal/system)'
   printf "%s\n" '  --enable-fuzzing         build fuzzing targets'
@@ -93,7 +94,6 @@ meson_options_help() {
   printf "%s\n" '  avx2            AVX2 optimizations'
   printf "%s\n" '  avx512bw        AVX512BW optimizations'
   printf "%s\n" '  avx512f         AVX512F optimizations'
-  printf "%s\n" '  enqcmd          ENQCMD optimizations'
   printf "%s\n" '  blkio           libblkio block device driver'
   printf "%s\n" '  bochs           bochs image format support'
   printf "%s\n" '  bpf             eBPF support'
@@ -241,8 +241,6 @@ _meson_option_parse() {
     --disable-avx512bw) printf "%s" -Davx512bw=disabled ;;
     --enable-avx512f) printf "%s" -Davx512f=enabled ;;
     --disable-avx512f) printf "%s" -Davx512f=disabled ;;
-    --enable-enqcmd) printf "%s" -Denqcmd=true ;;
-    --disable-enqcmd) printf "%s" -Denqcmd=false ;;
     --enable-gcov) printf "%s" -Db_coverage=true ;;
     --disable-gcov) printf "%s" -Db_coverage=false ;;
     --enable-lto) printf "%s" -Db_lto=true ;;
@@ -309,6 +307,8 @@ _meson_option_parse() {
     --disable-docs) printf "%s" -Ddocs=disabled ;;
     --enable-dsound) printf "%s" -Ddsound=enabled ;;
     --disable-dsound) printf "%s" -Ddsound=disabled ;;
+    --enable-enqcmd) printf "%s" -Denqcmd=true ;;
+    --disable-enqcmd) printf "%s" -Denqcmd=false ;;
     --enable-fdt) printf "%s" -Dfdt=enabled ;;
     --disable-fdt) printf "%s" -Dfdt=disabled ;;
     --enable-fdt=*) quote_sh "-Dfdt=$2" ;;
-- 
2.30.2
Re: [PATCH v2 12/20] migration/multifd: Add new migration option for multifd DSA offloading.
Posted by Wang, Lei 11 months, 2 weeks ago
On 11/14/2023 13:40, Hao Xiang wrote:
> Intel DSA offloading is an optional feature that turns on if
> proper hardware and software stack is available. To turn on
> DSA offloading in multifd live migration:
> 
> multifd-dsa-accel="[dsa_dev_path1] ] [dsa_dev_path2] ... [dsa_dev_pathX]"

Nit: a redundant bracket ]

> 
> This feature is turned off by default.
> 
> Signed-off-by: Hao Xiang <hao.xiang@bytedance.com>

[...]
Re: [PATCH v2 12/20] migration/multifd: Add new migration option for multifd DSA offloading.
Posted by Fabiano Rosas 11 months, 3 weeks ago
Hao Xiang <hao.xiang@bytedance.com> writes:

> Intel DSA offloading is an optional feature that turns on if
> proper hardware and software stack is available. To turn on
> DSA offloading in multifd live migration:
>
> multifd-dsa-accel="[dsa_dev_path1] ] [dsa_dev_path2] ... [dsa_dev_pathX]"
>
> This feature is turned off by default.

This patch breaks make check:

 43/357 qemu:qtest+qtest-x86_64 / qtest-x86_64/test-hmp               ERROR           0.52s
 79/357 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test         ERROR           3.59s
167/357 qemu:qtest+qtest-x86_64 / qtest-x86_64/qmp-cmd-test ERROR           3.68s

Make sure you run make check before posting. Ideally also run the series
through the Gitlab CI on your personal fork.

> Signed-off-by: Hao Xiang <hao.xiang@bytedance.com>
> ---
>  migration/migration-hmp-cmds.c |  8 ++++++++
>  migration/options.c            | 28 ++++++++++++++++++++++++++++
>  migration/options.h            |  1 +
>  qapi/migration.json            | 17 ++++++++++++++---
>  scripts/meson-buildoptions.sh  |  6 +++---
>  5 files changed, 54 insertions(+), 6 deletions(-)
>
> diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
> index 86ae832176..d9451744dd 100644
> --- a/migration/migration-hmp-cmds.c
> +++ b/migration/migration-hmp-cmds.c
> @@ -353,6 +353,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
>          monitor_printf(mon, "%s: '%s'\n",
>              MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ),
>              params->tls_authz);
> +        monitor_printf(mon, "%s: %s\n",

Use '%s' here.

> +            MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_DSA_ACCEL),
> +            params->multifd_dsa_accel);
>  
>          if (params->has_block_bitmap_mapping) {
>              const BitmapMigrationNodeAliasList *bmnal;
> @@ -615,6 +618,11 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
>          p->has_block_incremental = true;
>          visit_type_bool(v, param, &p->block_incremental, &err);
>          break;
> +    case MIGRATION_PARAMETER_MULTIFD_DSA_ACCEL:
> +        p->multifd_dsa_accel = g_new0(StrOrNull, 1);
> +        p->multifd_dsa_accel->type = QTYPE_QSTRING;
> +        visit_type_str(v, param, &p->multifd_dsa_accel->u.s, &err);
> +        break;
>      case MIGRATION_PARAMETER_MULTIFD_CHANNELS:
>          p->has_multifd_channels = true;
>          visit_type_uint8(v, param, &p->multifd_channels, &err);
> diff --git a/migration/options.c b/migration/options.c
> index 97d121d4d7..6e424b5d63 100644
> --- a/migration/options.c
> +++ b/migration/options.c
> @@ -179,6 +179,8 @@ Property migration_properties[] = {
>      DEFINE_PROP_MIG_MODE("mode", MigrationState,
>                        parameters.mode,
>                        MIG_MODE_NORMAL),
> +    DEFINE_PROP_STRING("multifd-dsa-accel", MigrationState,
> +                       parameters.multifd_dsa_accel),
>  
>      /* Migration capabilities */
>      DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE),
> @@ -901,6 +903,13 @@ const char *migrate_tls_creds(void)
>      return s->parameters.tls_creds;
>  }
>  
> +const char *migrate_multifd_dsa_accel(void)
> +{
> +    MigrationState *s = migrate_get_current();
> +
> +    return s->parameters.multifd_dsa_accel;
> +}
> +
>  const char *migrate_tls_hostname(void)
>  {
>      MigrationState *s = migrate_get_current();
> @@ -1025,6 +1034,7 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
>      params->vcpu_dirty_limit = s->parameters.vcpu_dirty_limit;
>      params->has_mode = true;
>      params->mode = s->parameters.mode;
> +    params->multifd_dsa_accel = s->parameters.multifd_dsa_accel;
>  
>      return params;
>  }
> @@ -1033,6 +1043,7 @@ void migrate_params_init(MigrationParameters *params)
>  {
>      params->tls_hostname = g_strdup("");
>      params->tls_creds = g_strdup("");
> +    params->multifd_dsa_accel = g_strdup("");
>  
>      /* Set has_* up only for parameter checks */
>      params->has_compress_level = true;
> @@ -1362,6 +1373,11 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
>      if (params->has_mode) {
>          dest->mode = params->mode;
>      }
> +
> +    if (params->multifd_dsa_accel) {
> +        assert(params->multifd_dsa_accel->type == QTYPE_QSTRING);
> +        dest->multifd_dsa_accel = params->multifd_dsa_accel->u.s;
> +    }
>  }
>  
>  static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
> @@ -1506,6 +1522,12 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
>      if (params->has_mode) {
>          s->parameters.mode = params->mode;
>      }
> +
> +    if (params->multifd_dsa_accel) {
> +        g_free(s->parameters.multifd_dsa_accel);
> +        assert(params->multifd_dsa_accel->type == QTYPE_QSTRING);
> +        s->parameters.multifd_dsa_accel = g_strdup(params->multifd_dsa_accel->u.s);
> +    }
>  }
>  
>  void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
> @@ -1531,6 +1553,12 @@ void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
>          params->tls_authz->type = QTYPE_QSTRING;
>          params->tls_authz->u.s = strdup("");
>      }
> +    if (params->multifd_dsa_accel
> +        && params->multifd_dsa_accel->type == QTYPE_QNULL) {
> +        qobject_unref(params->multifd_dsa_accel->u.n);
> +        params->multifd_dsa_accel->type = QTYPE_QSTRING;
> +        params->multifd_dsa_accel->u.s = strdup("");
> +    }
>  
>      migrate_params_test_apply(params, &tmp);
>  
> diff --git a/migration/options.h b/migration/options.h
> index c901eb57c6..56100961a9 100644
> --- a/migration/options.h
> +++ b/migration/options.h
> @@ -94,6 +94,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);
> +const char *migrate_multifd_dsa_accel(void);
>  
>  /* parameters setters */
>  
> diff --git a/qapi/migration.json b/qapi/migration.json
> index 9783289bfc..a8e3b66d6f 100644
> --- a/qapi/migration.json
> +++ b/qapi/migration.json
> @@ -879,6 +879,9 @@
>  # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
>  #        (Since 8.2)
>  #
> +# @multifd-dsa-accel: If enabled, use DSA accelerator offloading for
> +#                     certain memory operations. (since 8.2)
> +#
>  # Features:
>  #
>  # @deprecated: Member @block-incremental is deprecated.  Use
> @@ -902,7 +905,7 @@
>             'cpu-throttle-initial', 'cpu-throttle-increment',
>             'cpu-throttle-tailslow',
>             'tls-creds', 'tls-hostname', 'tls-authz', 'max-bandwidth',
> -           'avail-switchover-bandwidth', 'downtime-limit',
> +           'avail-switchover-bandwidth', 'downtime-limit', 'multifd-dsa-accel',
>             { 'name': 'x-checkpoint-delay', 'features': [ 'unstable' ] },
>             { 'name': 'block-incremental', 'features': [ 'deprecated' ] },
>             'multifd-channels',
> @@ -1067,6 +1070,9 @@
>  # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
>  #        (Since 8.2)
>  #
> +# @multifd-dsa-accel: If enabled, use DSA accelerator offloading for
> +#                     certain memory operations. (since 8.2)
> +#
>  # Features:
>  #
>  # @deprecated: Member @block-incremental is deprecated.  Use
> @@ -1120,7 +1126,8 @@
>              '*x-vcpu-dirty-limit-period': { 'type': 'uint64',
>                                              'features': [ 'unstable' ] },
>              '*vcpu-dirty-limit': 'uint64',
> -            '*mode': 'MigMode'} }
> +            '*mode': 'MigMode',
> +            '*multifd-dsa-accel': 'StrOrNull'} }
>  
>  ##
>  # @migrate-set-parameters:
> @@ -1295,6 +1302,9 @@
>  # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
>  #        (Since 8.2)
>  #
> +# @multifd-dsa-accel: If enabled, use DSA accelerator offloading for
> +#                     certain memory operations. (since 8.2)
> +#
>  # Features:
>  #
>  # @deprecated: Member @block-incremental is deprecated.  Use
> @@ -1345,7 +1355,8 @@
>              '*x-vcpu-dirty-limit-period': { 'type': 'uint64',
>                                              'features': [ 'unstable' ] },
>              '*vcpu-dirty-limit': 'uint64',
> -            '*mode': 'MigMode'} }
> +            '*mode': 'MigMode',
> +            '*multifd-dsa-accel': 'str'} }
>  
>  ##
>  # @query-migrate-parameters:
> diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> index bf139e3fb4..35222ab63e 100644
> --- a/scripts/meson-buildoptions.sh
> +++ b/scripts/meson-buildoptions.sh
> @@ -32,6 +32,7 @@ meson_options_help() {
>    printf "%s\n" '  --enable-debug-stack-usage'
>    printf "%s\n" '                           measure coroutine stack usage'
>    printf "%s\n" '  --enable-debug-tcg       TCG debugging'
> +  printf "%s\n" '  --enable-enqcmd          MENQCMD optimizations'
>    printf "%s\n" '  --enable-fdt[=CHOICE]    Whether and how to find the libfdt library'
>    printf "%s\n" '                           (choices: auto/disabled/enabled/internal/system)'
>    printf "%s\n" '  --enable-fuzzing         build fuzzing targets'
> @@ -93,7 +94,6 @@ meson_options_help() {
>    printf "%s\n" '  avx2            AVX2 optimizations'
>    printf "%s\n" '  avx512bw        AVX512BW optimizations'
>    printf "%s\n" '  avx512f         AVX512F optimizations'
> -  printf "%s\n" '  enqcmd          ENQCMD optimizations'
>    printf "%s\n" '  blkio           libblkio block device driver'
>    printf "%s\n" '  bochs           bochs image format support'
>    printf "%s\n" '  bpf             eBPF support'
> @@ -241,8 +241,6 @@ _meson_option_parse() {
>      --disable-avx512bw) printf "%s" -Davx512bw=disabled ;;
>      --enable-avx512f) printf "%s" -Davx512f=enabled ;;
>      --disable-avx512f) printf "%s" -Davx512f=disabled ;;
> -    --enable-enqcmd) printf "%s" -Denqcmd=true ;;
> -    --disable-enqcmd) printf "%s" -Denqcmd=false ;;
>      --enable-gcov) printf "%s" -Db_coverage=true ;;
>      --disable-gcov) printf "%s" -Db_coverage=false ;;
>      --enable-lto) printf "%s" -Db_lto=true ;;
> @@ -309,6 +307,8 @@ _meson_option_parse() {
>      --disable-docs) printf "%s" -Ddocs=disabled ;;
>      --enable-dsound) printf "%s" -Ddsound=enabled ;;
>      --disable-dsound) printf "%s" -Ddsound=disabled ;;
> +    --enable-enqcmd) printf "%s" -Denqcmd=true ;;
> +    --disable-enqcmd) printf "%s" -Denqcmd=false ;;
>      --enable-fdt) printf "%s" -Dfdt=enabled ;;
>      --disable-fdt) printf "%s" -Dfdt=disabled ;;
>      --enable-fdt=*) quote_sh "-Dfdt=$2" ;;
Re: [External] Re: [PATCH v2 12/20] migration/multifd: Add new migration option for multifd DSA offloading.
Posted by Hao Xiang 11 months, 2 weeks ago
On Mon, Dec 11, 2023 at 11:44 AM Fabiano Rosas <farosas@suse.de> wrote:
>
> Hao Xiang <hao.xiang@bytedance.com> writes:
>
> > Intel DSA offloading is an optional feature that turns on if
> > proper hardware and software stack is available. To turn on
> > DSA offloading in multifd live migration:
> >
> > multifd-dsa-accel="[dsa_dev_path1] ] [dsa_dev_path2] ... [dsa_dev_pathX]"
> >
> > This feature is turned off by default.
>
> This patch breaks make check:
>
>  43/357 qemu:qtest+qtest-x86_64 / qtest-x86_64/test-hmp               ERROR           0.52s
>  79/357 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test         ERROR           3.59s
> 167/357 qemu:qtest+qtest-x86_64 / qtest-x86_64/qmp-cmd-test ERROR           3.68s
>
> Make sure you run make check before posting. Ideally also run the series
> through the Gitlab CI on your personal fork.

* I think I accidentally deleted some code in meson-buildoptions.sh.
Reverted those now.
* I also found a bug in how I handle the string in migration options. Fixed now.
* make check is passing now. Fix will be in the next patchset.

69/818 qemu:qtest+qtest-x86_64 / qtest-x86_64/test-hmp
                   OK              4.22s   9 subtests passed
37/818 qemu:qtest+qtest-x86_64 / qtest-x86_64/migration-test
                   OK             60.16s   16 subtests passed
607/818 qemu:qtest+qtest-x86_64 / qtest-x86_64/qmp-cmd-test
                    OK              8.23s   65 subtests passed

Ok:                 747
Expected Fail:      0
Fail:               0
Unexpected Pass:    0
Skipped:            71
Timeout:            0

>
> > Signed-off-by: Hao Xiang <hao.xiang@bytedance.com>
> > ---
> >  migration/migration-hmp-cmds.c |  8 ++++++++
> >  migration/options.c            | 28 ++++++++++++++++++++++++++++
> >  migration/options.h            |  1 +
> >  qapi/migration.json            | 17 ++++++++++++++---
> >  scripts/meson-buildoptions.sh  |  6 +++---
> >  5 files changed, 54 insertions(+), 6 deletions(-)
> >
> > diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c
> > index 86ae832176..d9451744dd 100644
> > --- a/migration/migration-hmp-cmds.c
> > +++ b/migration/migration-hmp-cmds.c
> > @@ -353,6 +353,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
> >          monitor_printf(mon, "%s: '%s'\n",
> >              MigrationParameter_str(MIGRATION_PARAMETER_TLS_AUTHZ),
> >              params->tls_authz);
> > +        monitor_printf(mon, "%s: %s\n",
>
> Use '%s' here.

Fixed. Will be in the next version.

>
> > +            MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_DSA_ACCEL),
> > +            params->multifd_dsa_accel);
> >
> >          if (params->has_block_bitmap_mapping) {
> >              const BitmapMigrationNodeAliasList *bmnal;
> > @@ -615,6 +618,11 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDict *qdict)
> >          p->has_block_incremental = true;
> >          visit_type_bool(v, param, &p->block_incremental, &err);
> >          break;
> > +    case MIGRATION_PARAMETER_MULTIFD_DSA_ACCEL:
> > +        p->multifd_dsa_accel = g_new0(StrOrNull, 1);
> > +        p->multifd_dsa_accel->type = QTYPE_QSTRING;
> > +        visit_type_str(v, param, &p->multifd_dsa_accel->u.s, &err);
> > +        break;
> >      case MIGRATION_PARAMETER_MULTIFD_CHANNELS:
> >          p->has_multifd_channels = true;
> >          visit_type_uint8(v, param, &p->multifd_channels, &err);
> > diff --git a/migration/options.c b/migration/options.c
> > index 97d121d4d7..6e424b5d63 100644
> > --- a/migration/options.c
> > +++ b/migration/options.c
> > @@ -179,6 +179,8 @@ Property migration_properties[] = {
> >      DEFINE_PROP_MIG_MODE("mode", MigrationState,
> >                        parameters.mode,
> >                        MIG_MODE_NORMAL),
> > +    DEFINE_PROP_STRING("multifd-dsa-accel", MigrationState,
> > +                       parameters.multifd_dsa_accel),
> >
> >      /* Migration capabilities */
> >      DEFINE_PROP_MIG_CAP("x-xbzrle", MIGRATION_CAPABILITY_XBZRLE),
> > @@ -901,6 +903,13 @@ const char *migrate_tls_creds(void)
> >      return s->parameters.tls_creds;
> >  }
> >
> > +const char *migrate_multifd_dsa_accel(void)
> > +{
> > +    MigrationState *s = migrate_get_current();
> > +
> > +    return s->parameters.multifd_dsa_accel;
> > +}
> > +
> >  const char *migrate_tls_hostname(void)
> >  {
> >      MigrationState *s = migrate_get_current();
> > @@ -1025,6 +1034,7 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
> >      params->vcpu_dirty_limit = s->parameters.vcpu_dirty_limit;
> >      params->has_mode = true;
> >      params->mode = s->parameters.mode;
> > +    params->multifd_dsa_accel = s->parameters.multifd_dsa_accel;
> >
> >      return params;
> >  }
> > @@ -1033,6 +1043,7 @@ void migrate_params_init(MigrationParameters *params)
> >  {
> >      params->tls_hostname = g_strdup("");
> >      params->tls_creds = g_strdup("");
> > +    params->multifd_dsa_accel = g_strdup("");
> >
> >      /* Set has_* up only for parameter checks */
> >      params->has_compress_level = true;
> > @@ -1362,6 +1373,11 @@ static void migrate_params_test_apply(MigrateSetParameters *params,
> >      if (params->has_mode) {
> >          dest->mode = params->mode;
> >      }
> > +
> > +    if (params->multifd_dsa_accel) {
> > +        assert(params->multifd_dsa_accel->type == QTYPE_QSTRING);
> > +        dest->multifd_dsa_accel = params->multifd_dsa_accel->u.s;
> > +    }
> >  }
> >
> >  static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
> > @@ -1506,6 +1522,12 @@ static void migrate_params_apply(MigrateSetParameters *params, Error **errp)
> >      if (params->has_mode) {
> >          s->parameters.mode = params->mode;
> >      }
> > +
> > +    if (params->multifd_dsa_accel) {
> > +        g_free(s->parameters.multifd_dsa_accel);
> > +        assert(params->multifd_dsa_accel->type == QTYPE_QSTRING);
> > +        s->parameters.multifd_dsa_accel = g_strdup(params->multifd_dsa_accel->u.s);
> > +    }
> >  }
> >
> >  void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
> > @@ -1531,6 +1553,12 @@ void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
> >          params->tls_authz->type = QTYPE_QSTRING;
> >          params->tls_authz->u.s = strdup("");
> >      }
> > +    if (params->multifd_dsa_accel
> > +        && params->multifd_dsa_accel->type == QTYPE_QNULL) {
> > +        qobject_unref(params->multifd_dsa_accel->u.n);
> > +        params->multifd_dsa_accel->type = QTYPE_QSTRING;
> > +        params->multifd_dsa_accel->u.s = strdup("");
> > +    }
> >
> >      migrate_params_test_apply(params, &tmp);
> >
> > diff --git a/migration/options.h b/migration/options.h
> > index c901eb57c6..56100961a9 100644
> > --- a/migration/options.h
> > +++ b/migration/options.h
> > @@ -94,6 +94,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);
> > +const char *migrate_multifd_dsa_accel(void);
> >
> >  /* parameters setters */
> >
> > diff --git a/qapi/migration.json b/qapi/migration.json
> > index 9783289bfc..a8e3b66d6f 100644
> > --- a/qapi/migration.json
> > +++ b/qapi/migration.json
> > @@ -879,6 +879,9 @@
> >  # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
> >  #        (Since 8.2)
> >  #
> > +# @multifd-dsa-accel: If enabled, use DSA accelerator offloading for
> > +#                     certain memory operations. (since 8.2)
> > +#
> >  # Features:
> >  #
> >  # @deprecated: Member @block-incremental is deprecated.  Use
> > @@ -902,7 +905,7 @@
> >             'cpu-throttle-initial', 'cpu-throttle-increment',
> >             'cpu-throttle-tailslow',
> >             'tls-creds', 'tls-hostname', 'tls-authz', 'max-bandwidth',
> > -           'avail-switchover-bandwidth', 'downtime-limit',
> > +           'avail-switchover-bandwidth', 'downtime-limit', 'multifd-dsa-accel',
> >             { 'name': 'x-checkpoint-delay', 'features': [ 'unstable' ] },
> >             { 'name': 'block-incremental', 'features': [ 'deprecated' ] },
> >             'multifd-channels',
> > @@ -1067,6 +1070,9 @@
> >  # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
> >  #        (Since 8.2)
> >  #
> > +# @multifd-dsa-accel: If enabled, use DSA accelerator offloading for
> > +#                     certain memory operations. (since 8.2)
> > +#
> >  # Features:
> >  #
> >  # @deprecated: Member @block-incremental is deprecated.  Use
> > @@ -1120,7 +1126,8 @@
> >              '*x-vcpu-dirty-limit-period': { 'type': 'uint64',
> >                                              'features': [ 'unstable' ] },
> >              '*vcpu-dirty-limit': 'uint64',
> > -            '*mode': 'MigMode'} }
> > +            '*mode': 'MigMode',
> > +            '*multifd-dsa-accel': 'StrOrNull'} }
> >
> >  ##
> >  # @migrate-set-parameters:
> > @@ -1295,6 +1302,9 @@
> >  # @mode: Migration mode. See description in @MigMode. Default is 'normal'.
> >  #        (Since 8.2)
> >  #
> > +# @multifd-dsa-accel: If enabled, use DSA accelerator offloading for
> > +#                     certain memory operations. (since 8.2)
> > +#
> >  # Features:
> >  #
> >  # @deprecated: Member @block-incremental is deprecated.  Use
> > @@ -1345,7 +1355,8 @@
> >              '*x-vcpu-dirty-limit-period': { 'type': 'uint64',
> >                                              'features': [ 'unstable' ] },
> >              '*vcpu-dirty-limit': 'uint64',
> > -            '*mode': 'MigMode'} }
> > +            '*mode': 'MigMode',
> > +            '*multifd-dsa-accel': 'str'} }
> >
> >  ##
> >  # @query-migrate-parameters:
> > diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
> > index bf139e3fb4..35222ab63e 100644
> > --- a/scripts/meson-buildoptions.sh
> > +++ b/scripts/meson-buildoptions.sh
> > @@ -32,6 +32,7 @@ meson_options_help() {
> >    printf "%s\n" '  --enable-debug-stack-usage'
> >    printf "%s\n" '                           measure coroutine stack usage'
> >    printf "%s\n" '  --enable-debug-tcg       TCG debugging'
> > +  printf "%s\n" '  --enable-enqcmd          MENQCMD optimizations'
> >    printf "%s\n" '  --enable-fdt[=CHOICE]    Whether and how to find the libfdt library'
> >    printf "%s\n" '                           (choices: auto/disabled/enabled/internal/system)'
> >    printf "%s\n" '  --enable-fuzzing         build fuzzing targets'
> > @@ -93,7 +94,6 @@ meson_options_help() {
> >    printf "%s\n" '  avx2            AVX2 optimizations'
> >    printf "%s\n" '  avx512bw        AVX512BW optimizations'
> >    printf "%s\n" '  avx512f         AVX512F optimizations'
> > -  printf "%s\n" '  enqcmd          ENQCMD optimizations'
> >    printf "%s\n" '  blkio           libblkio block device driver'
> >    printf "%s\n" '  bochs           bochs image format support'
> >    printf "%s\n" '  bpf             eBPF support'
> > @@ -241,8 +241,6 @@ _meson_option_parse() {
> >      --disable-avx512bw) printf "%s" -Davx512bw=disabled ;;
> >      --enable-avx512f) printf "%s" -Davx512f=enabled ;;
> >      --disable-avx512f) printf "%s" -Davx512f=disabled ;;
> > -    --enable-enqcmd) printf "%s" -Denqcmd=true ;;
> > -    --disable-enqcmd) printf "%s" -Denqcmd=false ;;
> >      --enable-gcov) printf "%s" -Db_coverage=true ;;
> >      --disable-gcov) printf "%s" -Db_coverage=false ;;
> >      --enable-lto) printf "%s" -Db_lto=true ;;
> > @@ -309,6 +307,8 @@ _meson_option_parse() {
> >      --disable-docs) printf "%s" -Ddocs=disabled ;;
> >      --enable-dsound) printf "%s" -Ddsound=enabled ;;
> >      --disable-dsound) printf "%s" -Ddsound=disabled ;;
> > +    --enable-enqcmd) printf "%s" -Denqcmd=true ;;
> > +    --disable-enqcmd) printf "%s" -Denqcmd=false ;;
> >      --enable-fdt) printf "%s" -Dfdt=enabled ;;
> >      --disable-fdt) printf "%s" -Dfdt=disabled ;;
> >      --enable-fdt=*) quote_sh "-Dfdt=$2" ;;