diff mbox series

[v2,2/4] multifd: Implement multifd compression accelerator

Message ID 20231109154638.488213-3-yuan1.liu@intel.com (mailing list archive)
State New, archived
Headers show
Series Live Migration Acceleration with IAA Compression | expand

Commit Message

Liu, Yuan1 Nov. 9, 2023, 3:46 p.m. UTC
when starting multifd live migration, if the compression method is
enabled, compression method can be accelerated using accelerators.

Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Nanhai Zou <nanhai.zou@intel.com>
---
 migration/multifd.c | 38 ++++++++++++++++++++++++++++++++++++--
 migration/multifd.h |  8 ++++++++
 2 files changed, 44 insertions(+), 2 deletions(-)

--
2.39.3

Comments

Fabiano Rosas Nov. 24, 2023, 1:20 p.m. UTC | #1
Yuan Liu <yuan1.liu@intel.com> writes:

> when starting multifd live migration, if the compression method is
> enabled, compression method can be accelerated using accelerators.
>
> Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
> Reviewed-by: Nanhai Zou <nanhai.zou@intel.com>

Reviewed-by: Fabiano Rosas <farosas@suse.de>
Fabiano Rosas Dec. 1, 2023, 6:01 p.m. UTC | #2
Yuan Liu <yuan1.liu@intel.com> writes:

> when starting multifd live migration, if the compression method is
> enabled, compression method can be accelerated using accelerators.
>
> Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
> Reviewed-by: Nanhai Zou <nanhai.zou@intel.com>
> ---
>  migration/multifd.c | 38 ++++++++++++++++++++++++++++++++++++--
>  migration/multifd.h |  8 ++++++++
>  2 files changed, 44 insertions(+), 2 deletions(-)
>
> diff --git a/migration/multifd.c b/migration/multifd.c
> index 1fe53d3b98..7149e67867 100644
> --- a/migration/multifd.c
> +++ b/migration/multifd.c
> @@ -165,6 +165,34 @@ static MultiFDMethods multifd_nocomp_ops = {
>  static MultiFDMethods *multifd_ops[MULTIFD_COMPRESSION__MAX] = {
>      [MULTIFD_COMPRESSION_NONE] = &multifd_nocomp_ops,
>  };
> +static MultiFDAccelMethods *accel_multifd_ops[MULTIFD_COMPRESSION_ACCEL__MAX];
> +
> +static MultiFDMethods *get_multifd_ops(void)
> +{
> +    MultiFDCompression comp = migrate_multifd_compression();
> +    MultiFDCompressionAccel accel = migrate_multifd_compression_accel();
> +
> +    if (comp == MULTIFD_COMPRESSION_NONE ||
> +        accel == MULTIFD_COMPRESSION_ACCEL_NONE) {
> +        return multifd_ops[comp];
> +    }
> +    if (accel == MULTIFD_COMPRESSION_ACCEL_AUTO) {
> +        for (int i = 0; i < MULTIFD_COMPRESSION_ACCEL__MAX; i++) {
> +            if (accel_multifd_ops[i] &&
> +                accel_multifd_ops[i]->is_supported(comp)) {
> +                return accel_multifd_ops[i]->get_multifd_methods();
> +            }
> +        }
> +        return multifd_ops[comp];
> +    }
> +
> +    /* Check if a specified accelerator is available */
> +    if (accel_multifd_ops[accel] &&

The CI is complaining that we might reach here with accel=2 when
!CONFIG_QPL. It seems the assert at migrate_multifd_compression_accel is
not enough.
Liu, Yuan1 Dec. 4, 2023, 9:24 a.m. UTC | #3
> -----Original Message-----
> From: Fabiano Rosas <farosas@suse.de>
> Sent: Saturday, December 2, 2023 2:01 AM
> To: Liu, Yuan1 <yuan1.liu@intel.com>; quintela@redhat.com;
> peterx@redhat.com; leobras@redhat.com
> Cc: qemu-devel@nongnu.org; Liu, Yuan1 <yuan1.liu@intel.com>; Zou, Nanhai
> <nanhai.zou@intel.com>
> Subject: Re: [PATCH v2 2/4] multifd: Implement multifd compression
> accelerator
> 
> Yuan Liu <yuan1.liu@intel.com> writes:
> 
> > when starting multifd live migration, if the compression method is
> > enabled, compression method can be accelerated using accelerators.
> >
> > Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
> > Reviewed-by: Nanhai Zou <nanhai.zou@intel.com>
> > ---
> >  migration/multifd.c | 38 ++++++++++++++++++++++++++++++++++++--
> >  migration/multifd.h |  8 ++++++++
> >  2 files changed, 44 insertions(+), 2 deletions(-)
> >
> > diff --git a/migration/multifd.c b/migration/multifd.c index
> > 1fe53d3b98..7149e67867 100644
> > --- a/migration/multifd.c
> > +++ b/migration/multifd.c
> > @@ -165,6 +165,34 @@ static MultiFDMethods multifd_nocomp_ops = {
> > static MultiFDMethods *multifd_ops[MULTIFD_COMPRESSION__MAX] = {
> >      [MULTIFD_COMPRESSION_NONE] = &multifd_nocomp_ops,  };
> > +static MultiFDAccelMethods
> > +*accel_multifd_ops[MULTIFD_COMPRESSION_ACCEL__MAX];
> > +
> > +static MultiFDMethods *get_multifd_ops(void) {
> > +    MultiFDCompression comp = migrate_multifd_compression();
> > +    MultiFDCompressionAccel accel =
> > +migrate_multifd_compression_accel();
> > +
> > +    if (comp == MULTIFD_COMPRESSION_NONE ||
> > +        accel == MULTIFD_COMPRESSION_ACCEL_NONE) {
> > +        return multifd_ops[comp];
> > +    }
> > +    if (accel == MULTIFD_COMPRESSION_ACCEL_AUTO) {
> > +        for (int i = 0; i < MULTIFD_COMPRESSION_ACCEL__MAX; i++) {
> > +            if (accel_multifd_ops[i] &&
> > +                accel_multifd_ops[i]->is_supported(comp)) {
> > +                return accel_multifd_ops[i]->get_multifd_methods();
> > +            }
> > +        }
> > +        return multifd_ops[comp];
> > +    }
> > +
> > +    /* Check if a specified accelerator is available */
> > +    if (accel_multifd_ops[accel] &&
> 
> The CI is complaining that we might reach here with accel=2
> when !CONFIG_QPL. It seems the assert at migrate_multifd_compression_accel
> is not enough.
I will add assert to check both comp and accel next version in the get_multifd_ops function.
diff mbox series

Patch

diff --git a/migration/multifd.c b/migration/multifd.c
index 1fe53d3b98..7149e67867 100644
--- a/migration/multifd.c
+++ b/migration/multifd.c
@@ -165,6 +165,34 @@  static MultiFDMethods multifd_nocomp_ops = {
 static MultiFDMethods *multifd_ops[MULTIFD_COMPRESSION__MAX] = {
     [MULTIFD_COMPRESSION_NONE] = &multifd_nocomp_ops,
 };
+static MultiFDAccelMethods *accel_multifd_ops[MULTIFD_COMPRESSION_ACCEL__MAX];
+
+static MultiFDMethods *get_multifd_ops(void)
+{
+    MultiFDCompression comp = migrate_multifd_compression();
+    MultiFDCompressionAccel accel = migrate_multifd_compression_accel();
+
+    if (comp == MULTIFD_COMPRESSION_NONE ||
+        accel == MULTIFD_COMPRESSION_ACCEL_NONE) {
+        return multifd_ops[comp];
+    }
+    if (accel == MULTIFD_COMPRESSION_ACCEL_AUTO) {
+        for (int i = 0; i < MULTIFD_COMPRESSION_ACCEL__MAX; i++) {
+            if (accel_multifd_ops[i] &&
+                accel_multifd_ops[i]->is_supported(comp)) {
+                return accel_multifd_ops[i]->get_multifd_methods();
+            }
+        }
+        return multifd_ops[comp];
+    }
+
+    /* Check if a specified accelerator is available */
+    if (accel_multifd_ops[accel] &&
+        accel_multifd_ops[accel]->is_supported(comp)) {
+        return accel_multifd_ops[accel]->get_multifd_methods();
+    }
+    return multifd_ops[comp];
+}

 void multifd_register_ops(int method, MultiFDMethods *ops)
 {
@@ -172,6 +200,12 @@  void multifd_register_ops(int method, MultiFDMethods *ops)
     multifd_ops[method] = ops;
 }

+void multifd_register_accel_ops(int accel, MultiFDAccelMethods *ops)
+{
+    assert(0 < accel && accel < MULTIFD_COMPRESSION_ACCEL__MAX);
+    accel_multifd_ops[accel] = ops;
+}
+
 static int multifd_send_initial_packet(MultiFDSendParams *p, Error **errp)
 {
     MultiFDInit_t msg = {};
@@ -922,7 +956,7 @@  int multifd_save_setup(Error **errp)
     multifd_send_state->pages = multifd_pages_init(page_count);
     qemu_sem_init(&multifd_send_state->channels_ready, 0);
     qatomic_set(&multifd_send_state->exiting, 0);
-    multifd_send_state->ops = multifd_ops[migrate_multifd_compression()];
+    multifd_send_state->ops = get_multifd_ops();

     for (i = 0; i < thread_count; i++) {
         MultiFDSendParams *p = &multifd_send_state->params[i];
@@ -1180,7 +1214,7 @@  int multifd_load_setup(Error **errp)
     multifd_recv_state->params = g_new0(MultiFDRecvParams, thread_count);
     qatomic_set(&multifd_recv_state->count, 0);
     qemu_sem_init(&multifd_recv_state->sem_sync, 0);
-    multifd_recv_state->ops = multifd_ops[migrate_multifd_compression()];
+    multifd_recv_state->ops = get_multifd_ops();

     for (i = 0; i < thread_count; i++) {
         MultiFDRecvParams *p = &multifd_recv_state->params[i];
diff --git a/migration/multifd.h b/migration/multifd.h
index a835643b48..c40ff79443 100644
--- a/migration/multifd.h
+++ b/migration/multifd.h
@@ -206,7 +206,15 @@  typedef struct {
     int (*recv_pages)(MultiFDRecvParams *p, Error **errp);
 } MultiFDMethods;

+typedef struct {
+    /* Check if the compression method supports acceleration */
+    bool (*is_supported) (MultiFDCompression compression);
+    /* Get multifd methods of the accelerator */
+    MultiFDMethods* (*get_multifd_methods)(void);
+} MultiFDAccelMethods;
+
 void multifd_register_ops(int method, MultiFDMethods *ops);
+void multifd_register_accel_ops(int accel, MultiFDAccelMethods *ops);

 #endif